Submission #5559334
Source Code Expand
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; int R, C, N; struct point{ int x, y, id; }; int lev(point p){ if(p.y == 0) return 0; if(p.x == C) return 1; if(p.y == R) return 2; if(p.x == 0) return 3; return 4; } bool comp(point lhs, point rhs){ int levl = lev(lhs); int levr = lev(rhs); if(levl != levr) return levl < levr; if(levl == 0) return lhs.x < rhs.x; if(levl == 1) return lhs.y < rhs.y; if(levl == 2) return lhs.x > rhs.x; if(levl == 3) return lhs.y > rhs.y; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> R >> C >> N; vector<point> v; int id = 0; rep(i, N){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; point p1 = (point){x1, y1, id}; point p2 = (point){x2, y2, id}; if(lev(p1) < 4 && lev(p2) < 4){ v.push_back(p1); v.push_back(p2); id++; } } if(v.size() == 0){ cout << "Yes" << endl; return 0; } sort(v.begin(), v.end(), comp); stack<int> stc; set<int> st; for(int i = 0; i < v.size(); i++){ point p = v[i]; if(stc.size() == 0){ stc.push(p.id); st.insert(p.id); continue; } if(stc.top() == p.id){ stc.pop(); st.erase(p.id); continue; } auto itr = st.find(p.id); if(itr == st.end()){ stc.push(p.id); st.insert(p.id); }else{ cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Connected? |
User | misora192 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1490 Byte |
Status | WA |
Exec Time | 74 ms |
Memory | 3316 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 | WA | 49 ms | 1272 KB |
02.txt | WA | 48 ms | 1148 KB |
03.txt | WA | 52 ms | 1656 KB |
04.txt | WA | 40 ms | 576 KB |
05.txt | WA | 55 ms | 1912 KB |
06.txt | WA | 63 ms | 2420 KB |
07.txt | WA | 40 ms | 512 KB |
08.txt | WA | 50 ms | 1528 KB |
09.txt | WA | 45 ms | 1020 KB |
10.txt | WA | 52 ms | 1148 KB |
11.txt | WA | 53 ms | 1400 KB |
12.txt | WA | 37 ms | 256 KB |
13.txt | WA | 40 ms | 576 KB |
14.txt | WA | 49 ms | 1528 KB |
15.txt | WA | 52 ms | 1528 KB |
16.txt | WA | 39 ms | 384 KB |
17.txt | WA | 39 ms | 256 KB |
18.txt | WA | 37 ms | 256 KB |
19.txt | WA | 43 ms | 892 KB |
20.txt | WA | 61 ms | 2036 KB |
21.txt | WA | 46 ms | 892 KB |
22.txt | WA | 48 ms | 1528 KB |
23.txt | WA | 59 ms | 2420 KB |
24.txt | WA | 71 ms | 3188 KB |
25.txt | WA | 74 ms | 3316 KB |
26.txt | WA | 61 ms | 2164 KB |
27.txt | WA | 64 ms | 3188 KB |
28.txt | WA | 69 ms | 3060 KB |
29.txt | WA | 69 ms | 3316 KB |
30.txt | WA | 72 ms | 3188 KB |
43.txt | WA | 1 ms | 256 KB |
44.txt | WA | 1 ms | 256 KB |
45.txt | WA | 1 ms | 256 KB |
46.txt | WA | 1 ms | 256 KB |
s1.txt | WA | 1 ms | 256 KB |
s2.txt | WA | 1 ms | 256 KB |
s3.txt | WA | 1 ms | 256 KB |
s4.txt | WA | 1 ms | 256 KB |