CP00 Editorial

Problem link

Click here

Difficulty

Easy

Solution

We have one rectangle of dimension a\times b and another of dimension c\times d. To obtain a square by vertically stacking these two, their lengths must be equal (a = c) and the sum of their widths must be equal to their lengths (b + d = a = c). To obtain a square by horizontally stacking the rectangles, their widths must be equal (b = d) and the sum of their lengths must be equal to their widths (a + c = b = d).

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T;
	cin>>T;
	while(T--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a==c && (b+d)==a)
		 cout<<"Yes\n";
		else if(b==d && (a+c)==b)
		 cout<<"Yes\n";
		else
		 cout<<"No\n";
	}
	return 0;
	
}