标签:构造 不同的 osi pre nta include NPU mes air
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:
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; }
Codeforces Round #656 (Div. 3) A. Three Pairwise Maximums(思维/构造)
标签:构造 不同的 osi pre nta include NPU mes air
原文地址:https://www.cnblogs.com/lipoicyclic/p/13336317.html