Submission #2105442
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> using namespace std; typedef long long nyan; typedef pair<nyan,nyan> P; typedef pair<P,P> P2; nyan r,c; int n; P p1[100010]; P p2[100010]; bool on_edge(nyan a,nyan b) { return a == 0 || a == r || b == 0 || b == c; } nyan edge_point(P p) { if(p.second == 0) { return p.first; } if(p.first == r) { return r + p.second; } if(p.second == c) { return r + c + r - p.first; } if(p.first == 0) { return r + c + r + c - p.second; } return -1; } vector<nyan> xs,ys; int imos[800010]; int main() { cin >> r >> c >> n; xs.push_back(0); xs.push_back(r); ys.push_back(0); ys.push_back(c); for(int i = 0;i < n;i++) { cin >> p1[i].first >> p1[i].second >> p2[i].first >> p2[i].second; xs.push_back(p1[i].first); xs.push_back(p2[i].first); ys.push_back(p1[i].second); ys.push_back(p2[i].second); } sort(xs.begin(),xs.end()); sort(ys.begin(),ys.end()); xs.erase(unique(xs.begin(),xs.end()),xs.end()); ys.erase(unique(ys.begin(),ys.end()),ys.end()); r = xs.size() - 1; c = ys.size() - 1; vector<P> e_set; for(int i = 0;i < n;i++) { int x1,y1,x2,y2; x1 = lower_bound(xs.begin(),xs.end(),p1[i].first) - xs.begin(); y1 = lower_bound(ys.begin(),ys.end(),p1[i].second) - ys.begin(); x2 = lower_bound(xs.begin(),xs.end(),p2[i].first) - xs.begin(); y2 = lower_bound(ys.begin(),ys.end(),p2[i].second) - ys.begin(); if(on_edge(x1,y1) && on_edge(x2,y2)) { int e1 = edge_point(P(x1,y1)); int e2 = edge_point(P(x2,y2)); if(e1 > e2) swap(e1,e2); e_set.push_back(P(e1,e2)); imos[e1]++; imos[e2 + 1]--; } } for(int i = 1;i < r * 2 + c * 2;i++) { imos[i] += imos[i - 1]; } for(P e_s : e_set) { if(imos[e_s.first] != imos[e_s.second]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Connected? |
User | niuez |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2030 Byte |
Status | AC |
Exec Time | 237 ms |
Memory | 13284 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 | 187 ms | 12644 KB |
02.txt | AC | 205 ms | 11492 KB |
03.txt | AC | 198 ms | 11492 KB |
04.txt | AC | 217 ms | 10468 KB |
05.txt | AC | 202 ms | 12004 KB |
06.txt | AC | 187 ms | 12260 KB |
07.txt | AC | 232 ms | 10084 KB |
08.txt | AC | 197 ms | 11620 KB |
09.txt | AC | 215 ms | 11236 KB |
10.txt | AC | 191 ms | 12388 KB |
11.txt | AC | 193 ms | 12516 KB |
12.txt | AC | 232 ms | 9828 KB |
13.txt | AC | 219 ms | 10084 KB |
14.txt | AC | 190 ms | 11236 KB |
15.txt | AC | 208 ms | 11364 KB |
16.txt | AC | 233 ms | 9828 KB |
17.txt | AC | 237 ms | 9828 KB |
18.txt | AC | 230 ms | 9828 KB |
19.txt | AC | 207 ms | 10468 KB |
20.txt | AC | 185 ms | 12260 KB |
21.txt | AC | 216 ms | 11236 KB |
22.txt | AC | 206 ms | 11236 KB |
23.txt | AC | 186 ms | 13284 KB |
24.txt | AC | 184 ms | 12260 KB |
25.txt | AC | 182 ms | 12260 KB |
26.txt | AC | 183 ms | 12260 KB |
27.txt | AC | 181 ms | 12260 KB |
28.txt | AC | 174 ms | 12260 KB |
29.txt | AC | 182 ms | 12260 KB |
30.txt | AC | 182 ms | 12260 KB |
43.txt | AC | 2 ms | 4352 KB |
44.txt | AC | 2 ms | 4352 KB |
45.txt | AC | 2 ms | 4352 KB |
46.txt | AC | 2 ms | 4352 KB |
s1.txt | AC | 2 ms | 4352 KB |
s2.txt | AC | 2 ms | 4352 KB |
s3.txt | AC | 2 ms | 4352 KB |
s4.txt | AC | 2 ms | 4352 KB |