Submission #3806097
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[200100];
bool used[200100];
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 |
700 |
Code Size |
2269 Byte |
Status |
AC |
Exec Time |
169 ms |
Memory |
5248 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 |
148 ms |
4352 KB |
02.txt |
AC |
152 ms |
4352 KB |
03.txt |
AC |
154 ms |
4352 KB |
04.txt |
AC |
141 ms |
1280 KB |
05.txt |
AC |
155 ms |
4352 KB |
06.txt |
AC |
160 ms |
5120 KB |
07.txt |
AC |
144 ms |
768 KB |
08.txt |
AC |
156 ms |
4352 KB |
09.txt |
AC |
151 ms |
2048 KB |
10.txt |
AC |
163 ms |
4480 KB |
11.txt |
AC |
156 ms |
4352 KB |
12.txt |
AC |
139 ms |
384 KB |
13.txt |
AC |
140 ms |
896 KB |
14.txt |
AC |
139 ms |
4352 KB |
15.txt |
AC |
147 ms |
4352 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 |
AC |
164 ms |
4864 KB |
21.txt |
AC |
148 ms |
2048 KB |
22.txt |
AC |
149 ms |
4352 KB |
23.txt |
AC |
166 ms |
4992 KB |
24.txt |
AC |
168 ms |
5120 KB |
25.txt |
AC |
164 ms |
5248 KB |
26.txt |
AC |
164 ms |
5248 KB |
27.txt |
AC |
163 ms |
5248 KB |
28.txt |
AC |
157 ms |
5248 KB |
29.txt |
AC |
165 ms |
5248 KB |
30.txt |
AC |
169 ms |
5248 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 |