zoukankan      html  css  js  c++  java
  • Codeforces Round #656 (Div. 3) A. Three Pairwise Maximums(思维/构造)

    You are given three positive (i.e. strictly greater than zero) integers xx , yy and zz .

    Your task is to find positive integers aa , bb and cc such that x=max(a,b)x=max(a,b) , y=max(a,c)y=max(a,c) and z=max(b,c)z=max(b,c) , or determine that it is impossible to find such aa , bb and cc .

    You have to answer tt independent test cases. Print required aa , bb and cc in any (arbitrary) order.

    Input

    The first line of the input contains one integer tt (1≤t≤2⋅1041≤t≤2⋅104 ) — the number of test cases. Then tt test cases follow.

    The only line of the test case contains three integers xx , yy , and zz (1≤x,y,z≤1091≤x,y,z≤109 ).

    Output

    For each test case, print the answer:

    • "NO" in the only line of the output if a solution doesn't exist;
    • or "YES" in the first line and any valid triple of positive integers aa , bb and cc (1≤a,b,c≤1091≤a,b,c≤109 ) in the second line. You can print aa , bb and cc in any order.

    Example

    Input

    Copy

    5

    3 2 3

    100 100 100

    50 49 49

    10 30 20

    1 1000000000 1000000000

    Output

    Copy

    YES

    3 2 1

    YES

    100 100 100

    NO

    NO

    YES

    1 1 1000000000

    对三个数排一下序,三个等大的话直接输出,两等大一小的话除了这里面两个不同的数以外再构造一个1,其他情况都是不存在的。

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin >> t;
        while(t--)
        {
            int a[3];
            cin >> a[1] >> a[2] >> a[3];
            sort(a + 1, a +3 + 1);
            if(a[1] == a[2] && a[1] == a[3])
            {
                cout << "YES" <<endl;
                cout << a[1] << ' ' << a[2] << ' ' << a[3] << endl;
            }
            else if(a[2] == a[3])
            {
                cout << "YES" <<endl;
                cout << 1 << ' ' << a[1] << ' ' << a[3] << endl;
            }
            else cout << "NO" << endl;
        }
        return 0;
    }
  • 相关阅读:
    WHU 1572 Cyy and Fzz (AC自动机 dp )
    Codeforces 441D Valera and Swaps(置换群)
    Codeforces 527E Data Center Drama(欧拉回路)
    差分约束小结
    Codeforces 193D Two Segments 解题报告
    SGU 231.Prime Sum
    SGU 249.Matrix(Gray码)
    SGU 222.Little Rooks
    SGU 207.Robbers
    risc-v的寻址模式
  • 原文地址:https://www.cnblogs.com/lipoicyclic/p/13336317.html
Copyright © 2011-2022 走看看