Submission #3415996


Source Code Expand

#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int r,c,n;
struct point{
	int id,x,y;
}p[maxn];
int tot,top;
int s[maxn];
bool onedge(point x){return !x.x||!x.y||x.x==r||x.y==c;}
int calc(point x)
{
	if(x.y==0) return x.x;
    if(x.x==r) return r+x.y;
    if(x.y==c) return 2*r+c-x.x;
	if(x.x==0) return 2*r+2*c-x.y;
}
bool cmp(point x,point y){return calc(x)<calc(y);}
int main()
{
	r=read();c=read();n=read();
	for(int i=1;i<=n;i++)
	{
		point x1,x2;
		x1.id=x2.id=i;
		x1.x=read();x1.y=read();
		x2.x=read();x2.y=read();
		if(onedge(x1) && onedge(x2)) p[++tot]=x1,p[++tot]=x2;
	}
	sort(p+1,p+1+tot,cmp);
	for(int i=1;i<=tot;i++)
	{
		if(top && s[top]==p[i].id) top--;
		else s[++top]=p[i].id;
	}
	puts(top?"NO":"YES");
	return 0;
}

Submission Info

Submission Time
Task E - Connected?
User lijiamu
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1001 Byte
Status AC
Exec Time 62 ms
Memory 2944 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 38
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 44 ms 1920 KB
02.txt AC 42 ms 1664 KB
03.txt AC 44 ms 1664 KB
04.txt AC 32 ms 768 KB
05.txt AC 43 ms 1664 KB
06.txt AC 57 ms 2688 KB
07.txt AC 30 ms 512 KB
08.txt AC 47 ms 1920 KB
09.txt AC 37 ms 1152 KB
10.txt AC 53 ms 2560 KB
11.txt AC 49 ms 2176 KB
12.txt AC 27 ms 256 KB
13.txt AC 30 ms 512 KB
14.txt AC 37 ms 1408 KB
15.txt AC 39 ms 1408 KB
16.txt AC 29 ms 384 KB
17.txt AC 28 ms 256 KB
18.txt AC 27 ms 256 KB
19.txt AC 33 ms 896 KB
20.txt AC 57 ms 2816 KB
21.txt AC 37 ms 1152 KB
22.txt AC 39 ms 1280 KB
23.txt AC 58 ms 2944 KB
24.txt AC 58 ms 2944 KB
25.txt AC 57 ms 2816 KB
26.txt AC 57 ms 2944 KB
27.txt AC 56 ms 2816 KB
28.txt AC 56 ms 2944 KB
29.txt AC 58 ms 2816 KB
30.txt AC 62 ms 2816 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