Submission #2116000
Source Code Expand
#include<iostream> #include<algorithm> #include<stack> #include<vector> #define rep(i,n) for(int i = 0; i < n; ++i) using namespace std; using PII=pair<int,int>; vector<PII> l; int r, c, n; int x[2], y[2]; bool is_bor(int xs, int ys){ return xs == 0 || ys == 0 || xs == r || ys == c; } int main(void){ cin >> r >> c >> n; rep(i, n){ cin >> x[0] >> y[0] >> x[1] >> y[1]; if(is_bor(x[0], y[0]) && is_bor(x[1], y[1])){ rep(j, 2){ if(x[j] == 0){ l.push_back(PII(y[j], i)); }else if(y[j] == c){ l.push_back(PII(c+x[j], i)); }else if(x[j] == r){ l.push_back(PII(c+r+c-y[j], i)); }else if(y[j] == 0){ l.push_back(PII(c+r+c+r-x[j], i)); } } } } sort(l.begin(), l.end()); bool ok = true; stack<int> s; rep(i, l.size()){ int m = l[i].second; if(s.empty()){ s.push(m); }else{ if(s.top() == m){ s.pop(); }else{ s.push(m); } } } cout << (s.empty()?"YES":"NO") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Connected? |
User | ichigo |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1291 Byte |
Status | AC |
Exec Time | 151 ms |
Memory | 2420 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 | 132 ms | 2420 KB |
02.txt | AC | 138 ms | 1400 KB |
03.txt | AC | 141 ms | 1400 KB |
04.txt | AC | 136 ms | 892 KB |
05.txt | AC | 142 ms | 1400 KB |
06.txt | AC | 138 ms | 2420 KB |
07.txt | AC | 142 ms | 640 KB |
08.txt | AC | 140 ms | 1524 KB |
09.txt | AC | 141 ms | 1400 KB |
10.txt | AC | 143 ms | 2420 KB |
11.txt | AC | 140 ms | 2420 KB |
12.txt | AC | 137 ms | 256 KB |
13.txt | AC | 137 ms | 640 KB |
14.txt | AC | 129 ms | 1400 KB |
15.txt | AC | 138 ms | 1400 KB |
16.txt | AC | 140 ms | 512 KB |
17.txt | AC | 151 ms | 256 KB |
18.txt | AC | 137 ms | 256 KB |
19.txt | AC | 137 ms | 892 KB |
20.txt | AC | 142 ms | 2420 KB |
21.txt | AC | 141 ms | 1400 KB |
22.txt | AC | 140 ms | 1400 KB |
23.txt | AC | 144 ms | 2420 KB |
24.txt | AC | 144 ms | 2420 KB |
25.txt | AC | 143 ms | 2420 KB |
26.txt | AC | 144 ms | 2420 KB |
27.txt | AC | 143 ms | 2420 KB |
28.txt | AC | 134 ms | 2420 KB |
29.txt | AC | 142 ms | 2420 KB |
30.txt | AC | 144 ms | 2420 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 |