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;
}
复制代码

 

posted @   脂环  阅读(510)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示
主题色彩