Submission #3791398


Source Code Expand

/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define Fi first
#define Se second
#define MK make_pair
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e5;
int R,C,n,Mpcnt,tot,top;
pii A[(N<<1)+10];
bool check(int x,int y){return x==0||x==R||y==0||y==C;}
int stack[(N<<1)+10];
int get(int x,int y){
	if (y==0)	return x;
	if (x==R)	return R+y;
	if (y==C)	return 2*R+C-x;
	if (x==0)	return 2*R+2*C-y;
	return 0;
}
int main(){
	R=read(),C=read(),n=read();
	for (int i=1;i<=n;i++){
		int x1=read(),y1=read(),x2=read(),y2=read();
		if (!check(x1,y1)||!check(x2,y2))	continue;
		int x=get(x1,y1),y=get(x2,y2);
		A[++tot]=MK(x,i);
		A[++tot]=MK(y,i);
	}
	sort(A+1,A+1+tot);
	for (int i=1;i<=tot;i++){
		stack[++top]=i;
		if (A[stack[top]].Se==A[stack[top-1]].Se)	top-=2;
	}
	printf(top?"NO\n":"YES\n");
	return 0;
}

Submission Info

Submission Time
Task E - Connected?
User Wolfycz
Language C++ (GCC 5.4.1)
Score 700
Code Size 1580 Byte
Status AC
Exec Time 42 ms
Memory 2176 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 35 ms 2044 KB
02.txt AC 35 ms 1920 KB
03.txt AC 35 ms 1920 KB
04.txt AC 29 ms 1792 KB
05.txt AC 35 ms 1920 KB
06.txt AC 40 ms 2048 KB
07.txt AC 30 ms 1792 KB
08.txt AC 36 ms 2048 KB
09.txt AC 32 ms 1920 KB
10.txt AC 39 ms 2176 KB
11.txt AC 37 ms 2048 KB
12.txt AC 28 ms 1792 KB
13.txt AC 29 ms 1792 KB
14.txt AC 32 ms 1920 KB
15.txt AC 33 ms 1920 KB
16.txt AC 29 ms 1792 KB
17.txt AC 29 ms 1792 KB
18.txt AC 27 ms 1792 KB
19.txt AC 30 ms 1920 KB
20.txt AC 40 ms 2176 KB
21.txt AC 33 ms 1920 KB
22.txt AC 33 ms 1920 KB
23.txt AC 41 ms 2176 KB
24.txt AC 42 ms 2176 KB
25.txt AC 41 ms 2048 KB
26.txt AC 41 ms 2176 KB
27.txt AC 41 ms 2048 KB
28.txt AC 38 ms 2176 KB
29.txt AC 40 ms 2048 KB
30.txt AC 41 ms 2048 KB
43.txt AC 2 ms 1792 KB
44.txt AC 2 ms 1792 KB
45.txt AC 2 ms 1792 KB
46.txt AC 2 ms 1792 KB
s1.txt AC 2 ms 1792 KB
s2.txt AC 2 ms 1792 KB
s3.txt AC 2 ms 1792 KB
s4.txt AC 2 ms 1792 KB