Submission #3805865
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);
}
};
bool comp(const P& p,const P& q){
if(p.x!=q.x)return p.x<q.x;
return p.y<q.y;
}
vector<P> convex_hull(P* ps,int n){
sort(ps,ps+n,comp);
int k=0;
vector<P> qs(2*n);
for(int i=0;i<n;i++){
while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0ll)k--;
qs[k++]=ps[i];
}
for(int i=n-2,t=k;i>=0;i--){
while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<0ll)k--;
qs[k++]=ps[i];
}
qs.resize(k-1);
return qs;
}
int R,C,N;
int M;
P ps[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;
}
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;
vector<P> ch = convex_hull(ps,M);
assert(ch.size()==M);
/*for(int i=0;i<ch.size();i++){
cout << ch[i].x << ' ' << ch[i].y << ' ' << ch[i].val << endl;
}*/
int s = -1, t = -1;;
for(int i=0;i<ch.size();i++){
if(ch[i].val==ch[(i+1)%M].val){
s = i;
t = (i+1)%M;
}
}
if(s==-1){
printf("NO\n");
return 0;
}
for(int i=0;i<M/2;i++){
if(ch[s].val!=ch[t].val){
printf("NO\n");
return 0;
}
s = (s-1+M)%M;
t = (t+1)%M;
}
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 |
2450 Byte |
Status |
RE |
Exec Time |
220 ms |
Memory |
6272 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
RE |
190 ms |
2560 KB |
02.txt |
RE |
217 ms |
2560 KB |
03.txt |
RE |
213 ms |
2560 KB |
04.txt |
WA |
138 ms |
1920 KB |
05.txt |
RE |
220 ms |
2560 KB |
06.txt |
RE |
161 ms |
2560 KB |
07.txt |
AC |
143 ms |
1152 KB |
08.txt |
RE |
201 ms |
2560 KB |
09.txt |
AC |
145 ms |
3456 KB |
10.txt |
RE |
174 ms |
2560 KB |
11.txt |
RE |
190 ms |
2560 KB |
12.txt |
WA |
137 ms |
256 KB |
13.txt |
WA |
140 ms |
1408 KB |
14.txt |
AC |
135 ms |
6272 KB |
15.txt |
AC |
142 ms |
4480 KB |
16.txt |
WA |
141 ms |
640 KB |
17.txt |
WA |
143 ms |
384 KB |
18.txt |
WA |
141 ms |
384 KB |
19.txt |
AC |
141 ms |
2304 KB |
20.txt |
RE |
166 ms |
2560 KB |
21.txt |
AC |
145 ms |
3328 KB |
22.txt |
AC |
145 ms |
4608 KB |
23.txt |
RE |
164 ms |
2560 KB |
24.txt |
RE |
165 ms |
2560 KB |
25.txt |
RE |
161 ms |
2560 KB |
26.txt |
RE |
162 ms |
2560 KB |
27.txt |
RE |
160 ms |
2560 KB |
28.txt |
RE |
156 ms |
2560 KB |
29.txt |
RE |
161 ms |
2560 KB |
30.txt |
RE |
160 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 |