Submission #2106074
Source Code Expand
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<ll,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll h,w,n;
vector<P> vec;
bool ch(int x, int y){
if(x == h) return true;
if(x == 0) return true;
if(y == w) return true;
if(y == 0) return true;
return false;
}
ll f(int x, int y){
if(x == 0){
return (ll)y;
}else if(x == h){
return (ll)INF + (ll)INF + (ll)w - (ll)y;
}else if(y == 0){
return (ll)INF + (ll)INF + (ll)INF + (ll)h - (ll)x;
}else if(y == w){
return (ll)INF + (ll)x;
}
}
int main(){
cin >> h >> w >> n;
int c = 0;
REP(i,0,n){
int x,y,xx,yy; cin >> x >> y >> xx >> yy;
if(ch(x, y) and ch(xx, yy)){
vec.push_back({f(x, y), c});
vec.push_back({f(xx, yy), c++});
}
}
sort(vec.begin(), vec.end());
stack<int> st;
REP(i,0,vec.size()){
if(!st.empty() and st.top() == vec[i].second) st.pop();
else st.push(vec[i].second);
}
if(st.empty()) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Connected? |
User |
vjudge2 |
Language |
Bash (GNU bash v4.3.11) |
Score |
0 |
Code Size |
1251 Byte |
Status |
RE |
Exec Time |
4 ms |
Memory |
608 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 |
4 ms |
580 KB |
02.txt |
RE |
4 ms |
580 KB |
03.txt |
RE |
4 ms |
608 KB |
04.txt |
RE |
4 ms |
576 KB |
05.txt |
RE |
4 ms |
588 KB |
06.txt |
RE |
4 ms |
580 KB |
07.txt |
RE |
4 ms |
608 KB |
08.txt |
RE |
4 ms |
576 KB |
09.txt |
RE |
4 ms |
608 KB |
10.txt |
RE |
4 ms |
580 KB |
11.txt |
RE |
4 ms |
608 KB |
12.txt |
RE |
4 ms |
588 KB |
13.txt |
RE |
4 ms |
608 KB |
14.txt |
RE |
4 ms |
580 KB |
15.txt |
RE |
4 ms |
580 KB |
16.txt |
RE |
4 ms |
580 KB |
17.txt |
RE |
4 ms |
580 KB |
18.txt |
RE |
4 ms |
588 KB |
19.txt |
RE |
4 ms |
588 KB |
20.txt |
RE |
4 ms |
580 KB |
21.txt |
RE |
4 ms |
580 KB |
22.txt |
RE |
4 ms |
580 KB |
23.txt |
RE |
4 ms |
580 KB |
24.txt |
RE |
4 ms |
580 KB |
25.txt |
RE |
4 ms |
580 KB |
26.txt |
RE |
4 ms |
580 KB |
27.txt |
RE |
4 ms |
588 KB |
28.txt |
RE |
4 ms |
584 KB |
29.txt |
RE |
4 ms |
608 KB |
30.txt |
RE |
4 ms |
608 KB |
43.txt |
RE |
4 ms |
576 KB |
44.txt |
RE |
4 ms |
580 KB |
45.txt |
RE |
4 ms |
580 KB |
46.txt |
RE |
4 ms |
576 KB |
s1.txt |
RE |
4 ms |
580 KB |
s2.txt |
RE |
4 ms |
588 KB |
s3.txt |
RE |
4 ms |
580 KB |
s4.txt |
RE |
4 ms |
588 KB |