Submission #1534253
Source Code Expand
#include<bits/stdc++.h>
#define x first
#define p second
using namespace std;
typedef pair<int,int> point;
const int maxn = 100009;
vector<point> U, R, D, L;
int r, c, n, X1, X2, Y1, Y2;
int s[maxn], top;
void calc(int x){
if (top && s[top] == x) top--;
else s[++top] = x;
}
int main(){
scanf("%d%d%d", &r, &c, &n);
for (int i=1; i<=n; i++){
scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
if (X1 != 0 && X1 != r && Y1 != 0 && Y1 != c) continue;
if (X2 != 0 && X2 != r && Y2 != 0 && Y2 != c) continue;
if (X1 == 0) U.push_back(make_pair(Y1, i));
else if (Y1 == c) R.push_back(make_pair(X1, i));
else if (X1 == r) D.push_back(make_pair(Y1, i));
else L.push_back(make_pair(X1, i));
if (X2 == 0) U.push_back(make_pair(Y2, i));
else if (Y2 == c) R.push_back(make_pair(X2, i));
else if (X2 == r) D.push_back(make_pair(Y2, i));
else L.push_back(make_pair(X2, i));
}
sort(U.begin(), U.end()); sort(R.begin(), R.end());
sort(D.begin(), D.end()); sort(L.begin(), L.end());
for (int i=0; i<U.size(); i++) calc(U[i].p);
for (int i=0; i<R.size(); i++) calc(R[i].p);
for (int i=D.size()-1; i>=0; i--) calc(D[i].p);
for (int i=L.size()-1; i>=0; i--) calc(L[i].p);
puts(top == 0 ? "YES" : "NO");
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Connected? |
User |
Cyanic |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1260 Byte |
Status |
AC |
Exec Time |
52 ms |
Memory |
2584 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:18:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &r, &c, &n);
^
./Main.cpp:20:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
^
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 |
44 ms |
1592 KB |
02.txt |
AC |
44 ms |
1364 KB |
03.txt |
AC |
45 ms |
1528 KB |
04.txt |
AC |
39 ms |
836 KB |
05.txt |
AC |
45 ms |
1400 KB |
06.txt |
AC |
50 ms |
2416 KB |
07.txt |
AC |
39 ms |
512 KB |
08.txt |
AC |
46 ms |
1756 KB |
09.txt |
AC |
42 ms |
1016 KB |
10.txt |
AC |
49 ms |
2036 KB |
11.txt |
AC |
47 ms |
1736 KB |
12.txt |
AC |
37 ms |
256 KB |
13.txt |
AC |
39 ms |
640 KB |
14.txt |
AC |
41 ms |
1232 KB |
15.txt |
AC |
43 ms |
1188 KB |
16.txt |
AC |
38 ms |
384 KB |
17.txt |
AC |
38 ms |
256 KB |
18.txt |
AC |
37 ms |
256 KB |
19.txt |
AC |
40 ms |
1024 KB |
20.txt |
AC |
50 ms |
2520 KB |
21.txt |
AC |
42 ms |
976 KB |
22.txt |
AC |
43 ms |
1112 KB |
23.txt |
AC |
51 ms |
2312 KB |
24.txt |
AC |
51 ms |
2584 KB |
25.txt |
AC |
51 ms |
2096 KB |
26.txt |
AC |
52 ms |
2520 KB |
27.txt |
AC |
51 ms |
2224 KB |
28.txt |
AC |
49 ms |
2584 KB |
29.txt |
AC |
51 ms |
2236 KB |
30.txt |
AC |
51 ms |
2108 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 |