Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1376395

Source Code Expand

Copy
```/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int R,C,N;
vector<pair<pii,pii>> b;
int ans = 0;

int getint(pii x) {
if (x.s == 0) return x.f;
if (x.f == R) return R+x.s;
if (x.s == C) return 2*R+C-x.f;
return 2*R+2*C-x.s;
}

bool test() {
vi cur;
vector<pair<pii,int>> z;

int co = 0;
for (auto a: b) {
z.pb({{min(getint(a.f),getint(a.s)),1},co});
z.pb({{max(getint(a.f),getint(a.s)),-1},co});
co++;
}

sort(z.begin(),z.end());
for (auto a: z) {
if (a.f.s == 1) cur.pb(a.s);
else {
if (cur[cur.size()-1] != a.s) return 0;
cur.erase(cur.begin()+cur.size()-1);
}
}
return 1;
}

int main() {
cin >> R >> C >> N;
F0R(i,N) {
pair<pii,pii> x; cin >> x.f.f >> x.f.s >> x.s.f >> x.s.s;
if (x.f.f != 0 && x.f.f != R && x.f.s != 0 && x.f.s != C) continue;
if (x.s.f != 0 && x.s.f != R && x.s.s != 0 && x.s.s != C) continue;
b.pb(x);
}
if (test()) cout << "YES";
else cout << "NO";
}```

#### Submission Info

Submission Time 2017-06-24 21:50:38+0900 E - Connected? Benq C++14 (GCC 5.4.1) 700 1779 Byte AC 152 ms 7664 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt, s4.txt
All 700 / 700 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 134 ms 7408 KB
02.txt 139 ms 3444 KB
03.txt 143 ms 3444 KB
04.txt 138 ms 1656 KB
05.txt 144 ms 3444 KB
06.txt 142 ms 7024 KB
07.txt 143 ms 956 KB
08.txt 142 ms 3572 KB
09.txt 143 ms 3060 KB
10.txt 146 ms 7408 KB
11.txt 142 ms 6000 KB
12.txt 138 ms 256 KB
13.txt 139 ms 956 KB
14.txt 132 ms 3188 KB
15.txt 139 ms 3188 KB
16.txt 141 ms 640 KB
17.txt 144 ms 384 KB
18.txt 137 ms 256 KB
19.txt 139 ms 1784 KB
20.txt 145 ms 7664 KB
21.txt 142 ms 3060 KB
22.txt 142 ms 3188 KB
23.txt 147 ms 7536 KB
24.txt 146 ms 7024 KB
25.txt 146 ms 6384 KB
26.txt 150 ms 7152 KB
27.txt 152 ms 7536 KB
28.txt 138 ms 6384 KB
29.txt 146 ms 7280 KB
30.txt 146 ms 6384 KB
43.txt 1 ms 256 KB
44.txt 1 ms 256 KB
45.txt 1 ms 256 KB
46.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB
s4.txt 1 ms 256 KB