Submission #5494621


Source Code Expand

#include<cstdio>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
stack<int> st;
int ch[100010];
vector<pair<int,int>> vt[4];
int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= k; i++) {
		int q, w, e, r;
		scanf("%d %d %d %d", &q, &w, &e, &r);
		if ((q == 0 || q == n || w == 0 || w == m) && (e == 0 || e == n || r == 0 || r == m)) {
			if (q == 0)
				vt[0].push_back({ w,i });
			else if (w == m)
				vt[1].push_back({ q,i });
			else if (q == n)
				vt[2].push_back({ w,i });
			else if (w == 0)
				vt[3].push_back({ q,i });
			if (e == 0)
				vt[0].push_back({ r,i });
			else if (r == m)
				vt[1].push_back({ e,i });
			else if (n == e)
				vt[2].push_back({ r,i });
			else if (r == 0)
				vt[3].push_back({ e,i });
		}
	}
	for (int i = 0; i < 4; i++) 
		sort(vt[i].begin(), vt[i].end());
	for (int i = 2; i < 4; i++)
		reverse(vt[i].begin(), vt[i].end());
	for (int i = 0; i < 4; i++) {
		for (int y = 0; y < vt[i].size(); y++) {
			int next = vt[i][y].second;
			ch[next]++;
			if (ch[next] == 1)
				st.push(next);
			else {
				if (st.top() != next) {
					puts("NO");
					return 0;
				}
				else st.pop();
			}
		}
	}
	puts("YES");
}

Submission Info

Submission Time
Task E - Connected?
User njchung99
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1258 Byte
Status AC
Exec Time 53 ms
Memory 2588 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
                               ^
./Main.cpp:15:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &q, &w, &e, &r);
                                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 38
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 46 ms 1848 KB
02.txt AC 45 ms 1620 KB
03.txt AC 46 ms 1776 KB
04.txt AC 40 ms 1084 KB
05.txt AC 45 ms 1656 KB
06.txt AC 52 ms 2412 KB
07.txt AC 39 ms 896 KB
08.txt AC 47 ms 1880 KB
09.txt AC 42 ms 1272 KB
10.txt AC 50 ms 2156 KB
11.txt AC 47 ms 1864 KB
12.txt AC 37 ms 384 KB
13.txt AC 39 ms 1004 KB
14.txt AC 42 ms 1484 KB
15.txt AC 43 ms 1444 KB
16.txt AC 39 ms 768 KB
17.txt AC 38 ms 640 KB
18.txt AC 37 ms 640 KB
19.txt AC 40 ms 1280 KB
20.txt AC 52 ms 2516 KB
21.txt AC 43 ms 1232 KB
22.txt AC 43 ms 1360 KB
23.txt AC 51 ms 2308 KB
24.txt AC 51 ms 2584 KB
25.txt AC 53 ms 2352 KB
26.txt AC 52 ms 2520 KB
27.txt AC 52 ms 2352 KB
28.txt AC 50 ms 2588 KB
29.txt AC 52 ms 2364 KB
30.txt AC 52 ms 2364 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