Codeforces Round #497 (Div. 2)B. Turn the Rectangles

时间:2024-12-05 22:05:56

Bryce1010模板

http://codeforces.com/contest/1008/problems

#include <bits/stdc++.h>

using namespace std;
#define ll long long
const int MAXN=1e5+10;
const int INF=0x3f3f3f3f;
struct REC
{
int w,h;
}rec[MAXN]; int n;
int main()
{
//cout << "Hello world!" << endl;
cin>>n;
rec[0].h=INF;
bool flag=true;
for(int i=1;i<=n;i++)
{
cin>>rec[i].w>>rec[i].h;
if(max(rec[i].w,rec[i].h)<=rec[i-1].h)
rec[i].h=max(rec[i].w,rec[i].h);
else if(min(rec[i].w,rec[i].h)<=rec[i-1].h)
rec[i].h=min(rec[i].w,rec[i].h);
else if(min(rec[i].w,rec[i].h)>rec[i-1].h)
flag=false;
}
if(flag)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}