Submission #11587741
Source Code Expand
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
#define pb push_back
const int maxn=1e5+6;
struct point{int id,val;};
vector<point> v[4];
int n,r,c,s[maxn<<1],top=0;
inline bool check(int x,int y){
if(x==0||x==r||y==0||y==c)return 1;else return 0;
}
void push(int id,int x,int y){
if(x==0)v[0].pb({id,y});
else if(y==c)v[1].pb({id,x});
else if(x==r)v[2].pb({id,y});
else if(y==0)v[3].pb({id,x});
}
inline bool cmp1(point a,point b){return a.val<b.val;}
inline bool cmp2(point a,point b){return a.val>b.val;}
int main()
{
r=read(),c=read(),n=read();
rep(i,1,n){
int X1=read(),Y1=read(),X2=read(),Y2=read();
if(check(X1,Y1)&&check(X2,Y2))push(i,X1,Y1),push(i,X2,Y2);
}
sort(v[0].begin(),v[0].end(),cmp1);
sort(v[1].begin(),v[1].end(),cmp1);
sort(v[2].begin(),v[2].end(),cmp2);
sort(v[3].begin(),v[3].end(),cmp2);
rep(j,0,3)
for(int i=0;i<v[j].size();i++){
if(top==0){s[++top]=v[j][i].id;continue;}
if(s[top]==v[j][i].id)top--;else s[++top]=v[j][i].id;
}
if(top==0)puts("YES");else puts("NO");
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Connected? |
User |
vjudge5 |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1594 Byte |
Status |
AC |
Exec Time |
45 ms |
Memory |
2584 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
700 / 700 |
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, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 43.txt, 44.txt, 45.txt, 46.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
37 ms |
1592 KB |
02.txt |
AC |
35 ms |
1364 KB |
03.txt |
AC |
36 ms |
1528 KB |
04.txt |
AC |
29 ms |
836 KB |
05.txt |
AC |
36 ms |
1400 KB |
06.txt |
AC |
43 ms |
2416 KB |
07.txt |
AC |
29 ms |
512 KB |
08.txt |
AC |
38 ms |
1756 KB |
09.txt |
AC |
32 ms |
1016 KB |
10.txt |
AC |
42 ms |
2036 KB |
11.txt |
AC |
39 ms |
1736 KB |
12.txt |
AC |
26 ms |
256 KB |
13.txt |
AC |
28 ms |
640 KB |
14.txt |
AC |
31 ms |
1232 KB |
15.txt |
AC |
34 ms |
1188 KB |
16.txt |
AC |
28 ms |
384 KB |
17.txt |
AC |
28 ms |
256 KB |
18.txt |
AC |
26 ms |
256 KB |
19.txt |
AC |
30 ms |
1024 KB |
20.txt |
AC |
43 ms |
2520 KB |
21.txt |
AC |
32 ms |
976 KB |
22.txt |
AC |
33 ms |
1112 KB |
23.txt |
AC |
44 ms |
2312 KB |
24.txt |
AC |
44 ms |
2456 KB |
25.txt |
AC |
44 ms |
2096 KB |
26.txt |
AC |
45 ms |
2520 KB |
27.txt |
AC |
44 ms |
2224 KB |
28.txt |
AC |
42 ms |
2584 KB |
29.txt |
AC |
44 ms |
2236 KB |
30.txt |
AC |
44 ms |
2108 KB |
43.txt |
AC |
1 ms |
256 KB |
44.txt |
AC |
1 ms |
256 KB |
45.txt |
AC |
1 ms |
256 KB |
46.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
1 ms |
256 KB |
s4.txt |
AC |
1 ms |
256 KB |