↵
↵
### Idea↵
↵
We are given four values:↵
↵
`l, r, d, u`↵
↵
For these four points to form a square, all four distances need to be equal.↵
↵
The usual way is to check:↵
↵
```cpp↵
l == r && r == d && d == u↵
```↵
↵
But I used a different and simple way.↵
↵
First, I find the **minimum** and **maximum** among the four values.↵
↵
```cpp↵
ll mn = min({l, r, d, u});↵
ll mx = max({l, r, d, u});↵
```↵
↵
Now notice:↵
↵
* If all four values are equal, the minimum and maximum will also be equal.↵
* If the minimum and maximum are different, then at least one value is different.↵
↵
So the condition becomes:↵
↵
```text↵
mn == mx → YES↵
mn != mx → NO↵
```↵
↵
### Code↵
↵
```cpp↵
#include <bits/stdc++.h>↵
using namespace std;↵
↵
#define ll long long↵
↵
int32_t main()↵
{↵
ios_base::sync_with_stdio(false);↵
cin.tie(nullptr);↵
↵
ll t;↵
cin >> t;↵
↵
while (t--)↵
{↵
ll l, r, d, u;↵
cin >> l >> r >> d >> u;↵
↵
ll mn = min({l, r, d, u});↵
ll mx = max({l, r, d, u});↵
↵
if (mn == mx)↵
cout << "YES\n";↵
else↵
cout << "NO\n";↵
}↵
}↵
```↵
### Example 1↵
Suppose:↵
```text↵
2 2 2 2↵
```↵
↵
Then:↵
```text↵
mn = 2↵
mx = 2↵
```↵
So `mn == mx`, therefore the answer is:↵
↵
```text↵
YES↵
```↵
### Example 2↵
↵
Suppose:↵
```text↵
1 2 1 1↵
```↵
↵
Then:↵
```text↵
mn = 1↵
mx = 2↵
```↵
↵
So `mn != mx`, therefore the answer is:↵
```text↵
NO↵
```↵
↵
### Complexity↵
For each test case:↵
* **Time:** `O(1)`↵
* **Space:** `O(1)`↵
↵
This is basically the same condition as checking all four values directly, but using the minimum and maximum gives another simple way to think about the problem.↵



