Submission #3416048
Source Code Expand
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 400020
using namespace std;
int read(){
int nm=0,fh=1; int cw=getchar();
for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
return nm*fh;
}
int H,W,n,X[M],Y[M],XX[M],YY[M],L[M<<2],R[M<<2],od[M<<2];
bool on(int x,int y){return x==0||y==0||x==H||y==W;}
int bas(int x,int y){if(!x)return y;if(y==W)return W+x;if(x==H)return W+H+W-y;return W+H+W-x;}
bool cmp(int x,int y){return R[x]<R[y]||(R[x]==R[y]&&L[x]>L[y]);}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
H=read(),W=read(),n=read();
for(int i=1;i<=n;i++){
X[i]=read(),Y[i]=read(),XX[i]=read(),YY[i]=read(),od[i]=i;
if(!on(X[i],Y[i])||!on(XX[i],YY[i])) i--,n--;
L[i]=bas(X[i],Y[i]),R[i]=bas(XX[i],YY[i]);
if(L[i]>R[i]) swap(L[i],R[i]);
}
sort(od+1,od+n+1,cmp);
for(int i=1;i<=n;i++){
od[i+n]=od[i]+n,L[i+n]=R[i],R[i+n]=L[i]+W+H+W+H;
od[i+n+n]=od[i]+n+n,L[i+n+n]=L[i]+W+H+W+H,R[i+n+n]=R[i]+W+H+W+H;
od[i+n+n+n]=od[i]+n+n+n,L[i+n+n+n]=L[i+n]+W+H+W+H,R[i+n+n+n]=R[i+n]+W+H+W+H;
}
for(int i=2;i<=(n<<2);i++) if(L[od[i-1]]<L[od[i]]&&R[od[i-1]]<R[od[i]]&&L[od[i]]<R[od[i-1]]){puts("NO");return 0;}
puts("YES"); return 0;
}
Submission Info
Submission Time |
|
Task |
C - Reconciled? |
User |
OYJason |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1330 Byte |
Status |
TLE |
Exec Time |
2103 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt, s4.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
TLE |
2103 ms |
256 KB |
02.txt |
TLE |
2103 ms |
256 KB |
03.txt |
TLE |
2103 ms |
256 KB |
04.txt |
TLE |
2103 ms |
256 KB |
05.txt |
TLE |
2103 ms |
256 KB |
06.txt |
TLE |
2103 ms |
256 KB |
07.txt |
TLE |
2103 ms |
256 KB |
08.txt |
TLE |
2103 ms |
256 KB |
09.txt |
TLE |
2103 ms |
256 KB |
10.txt |
TLE |
2103 ms |
256 KB |
11.txt |
TLE |
2103 ms |
256 KB |
12.txt |
TLE |
2103 ms |
256 KB |
s1.txt |
TLE |
2103 ms |
256 KB |
s2.txt |
TLE |
2103 ms |
256 KB |
s3.txt |
TLE |
2103 ms |
256 KB |
s4.txt |
TLE |
2103 ms |
256 KB |