Submission #3806094


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll add(ll a,ll b){
	return a+b;
}
struct P{
	ll x,y;
	int val;
	P() {}
	P(ll x,ll y):x(x),y(y){}
	P(ll x,ll y,int val):x(x),y(y),val(val){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x,d*y);
	}
	ll dot(P p){
		return add(x*p.x,y*p.y);
	}
	ll det(P p){
		return add(x*p.y,-y*p.x);
	}
};

int R,C,N;
int M;
P ps[100100];
bool used[100100];
bool Xedge(int x){
	if(x==0||x==R)return true;
	else return false;
}
bool Yedge(int y){
	if(y==0||y==C)return true;
	else return false;
}
pair<ll,ll> idx(P a){
	pair<ll,ll> ret;
	if(a.y==0ll&&a.x<R){
		ret.fi=0;ret.sec=a.x;
	}else if(a.x==R&&a.y<C){
		ret.fi=1;ret.sec=a.y;
	}else if(a.y==C&&a.x>0ll){
		ret.fi=2;ret.sec=R-a.x;
	}else{
		ret.fi=3;ret.sec=C-a.y;
	}
	return ret;
}
bool comp(const P& p,const P& q){
	return idx(p)<idx(q);
}
int main(){
	cin >> R >> C >> N;
	for(int i=0;i<N;i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if((Xedge(x1)||Yedge(y1))&&(Xedge(x2)||Yedge(y2))){
			ps[2*M]=P(x1,y1,i+1);
			ps[2*M+1]=P(x2,y2,i+1);
			M++;
		}
	}
	M*=2;
	sort(ps,ps+M,comp);
	//vector<P> ch = convex_hull(ps,M);
	//assert(ch.size()==M);
	/*for(int i=0;i<M;i++){
		cout << ps[i].x << ' ' << ps[i].y << ' ' << ps[i].val << endl;
 	}*/
 	stack<int> s;
 	for(int i=0;i<M;i++){
 		int c = ps[i].val;
 		if(used[c]){
 			if(s.top()!=c){
 				printf("NO\n");
 				return 0;
 			}
 			s.pop();
 		}else{
 			s.push(c);
 			used[c]=true;
 		}
 	}
 	printf("YES\n");
	return 0;
}

Submission Info

Submission Time
Task E - Connected?
User okura
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2269 Byte
Status RE
Exec Time 214 ms
Memory 2560 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 4
AC × 24
WA × 2
RE × 12
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 94 ms 2560 KB
02.txt AC 120 ms 2560 KB
03.txt RE 214 ms 2560 KB
04.txt AC 141 ms 1280 KB
05.txt AC 125 ms 2560 KB
06.txt RE 162 ms 2560 KB
07.txt AC 145 ms 768 KB
08.txt RE 204 ms 2560 KB
09.txt AC 149 ms 2048 KB
10.txt WA 78 ms 2560 KB
11.txt RE 191 ms 2560 KB
12.txt AC 138 ms 384 KB
13.txt AC 141 ms 896 KB
14.txt AC 139 ms 2432 KB
15.txt AC 154 ms 2432 KB
16.txt AC 142 ms 640 KB
17.txt AC 144 ms 384 KB
18.txt AC 138 ms 384 KB
19.txt AC 143 ms 1408 KB
20.txt WA 70 ms 2560 KB
21.txt AC 149 ms 1920 KB
22.txt AC 150 ms 2304 KB
23.txt RE 165 ms 2560 KB
24.txt RE 165 ms 2560 KB
25.txt RE 161 ms 2560 KB
26.txt RE 166 ms 2560 KB
27.txt RE 167 ms 2560 KB
28.txt RE 160 ms 2560 KB
29.txt RE 163 ms 2560 KB
30.txt RE 163 ms 2560 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