Submission #299528

# Submission time Handle Problem Language Result Execution time Memory
299528 2020-09-15T06:17:34 Z E869120 Joker (BOI20_joker) C++14
14 / 100
2000 ms 18296 KB
#include <bits/stdc++.h>
using namespace std;

// Input
int N;
int M, A[1 << 18], B[1 << 18];
int Q, L[1 << 18], R[1 << 18];

// Graph
vector<int> X[1 << 18];
int col[1 << 18];
bool flag;

void dfs(int pos, int dep) {
	col[pos] = dep;
	for (int i : X[pos]) {
		if (col[i] != -1) {
			if (col[i] == dep) flag = true;
			continue;
		}
		dfs(i, dep ^ 1);
	}
}

bool solve(int l, int r) {
	flag = false;
	for (int i = 1; i <= N; i++) X[i].clear();
	for (int i = 1; i <= M; i++) {
		if (l <= i && i <= r) continue;
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	for (int i = 1; i <= N; i++) col[i] = -1;
	for (int i = 1; i <= N; i++) {
		if (col[i] >= 0) continue;
		dfs(i, 0);
	}
	return flag;
}

void solve_subtask1() {
	for (int i = 1; i <= Q; i++) {
		bool ans = solve(L[i], R[i]);
		if (ans == false) printf("NO\n");
		else printf("YES\n");
	}
}

int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 1; i <= M; i++) scanf("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= Q; i++) scanf("%d%d", &L[i], &R[i]);
	
	solve_subtask1();
	return 0;
}

Compilation message

Joker.cpp: In function 'int main()':
Joker.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |  scanf("%d%d%d", &N, &M, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:51:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |  for (int i = 1; i <= M; i++) scanf("%d%d", &A[i], &B[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:52:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |  for (int i = 1; i <= Q; i++) scanf("%d%d", &L[i], &R[i]);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Correct 5 ms 6528 KB Output is correct
4 Correct 5 ms 6528 KB Output is correct
5 Correct 4 ms 6528 KB Output is correct
6 Correct 4 ms 6528 KB Output is correct
7 Correct 5 ms 6528 KB Output is correct
8 Correct 6 ms 6528 KB Output is correct
9 Correct 6 ms 6528 KB Output is correct
10 Correct 6 ms 6528 KB Output is correct
11 Correct 6 ms 6656 KB Output is correct
12 Correct 6 ms 6528 KB Output is correct
13 Correct 5 ms 6528 KB Output is correct
14 Correct 6 ms 6528 KB Output is correct
15 Correct 6 ms 6528 KB Output is correct
16 Correct 6 ms 6528 KB Output is correct
17 Correct 6 ms 6528 KB Output is correct
18 Correct 5 ms 6528 KB Output is correct
19 Correct 6 ms 6528 KB Output is correct
20 Correct 6 ms 6528 KB Output is correct
21 Correct 6 ms 6528 KB Output is correct
22 Correct 6 ms 6528 KB Output is correct
23 Correct 5 ms 6528 KB Output is correct
24 Correct 6 ms 6528 KB Output is correct
25 Correct 7 ms 6528 KB Output is correct
26 Correct 5 ms 6528 KB Output is correct
27 Correct 6 ms 6528 KB Output is correct
28 Correct 6 ms 6528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Correct 5 ms 6528 KB Output is correct
4 Correct 5 ms 6528 KB Output is correct
5 Correct 4 ms 6528 KB Output is correct
6 Correct 4 ms 6528 KB Output is correct
7 Correct 5 ms 6528 KB Output is correct
8 Correct 6 ms 6528 KB Output is correct
9 Correct 6 ms 6528 KB Output is correct
10 Correct 6 ms 6528 KB Output is correct
11 Correct 6 ms 6656 KB Output is correct
12 Correct 6 ms 6528 KB Output is correct
13 Correct 5 ms 6528 KB Output is correct
14 Correct 6 ms 6528 KB Output is correct
15 Correct 6 ms 6528 KB Output is correct
16 Correct 6 ms 6528 KB Output is correct
17 Correct 6 ms 6528 KB Output is correct
18 Correct 5 ms 6528 KB Output is correct
19 Correct 6 ms 6528 KB Output is correct
20 Correct 6 ms 6528 KB Output is correct
21 Correct 6 ms 6528 KB Output is correct
22 Correct 6 ms 6528 KB Output is correct
23 Correct 5 ms 6528 KB Output is correct
24 Correct 6 ms 6528 KB Output is correct
25 Correct 7 ms 6528 KB Output is correct
26 Correct 5 ms 6528 KB Output is correct
27 Correct 6 ms 6528 KB Output is correct
28 Correct 6 ms 6528 KB Output is correct
29 Correct 114 ms 6648 KB Output is correct
30 Correct 155 ms 6656 KB Output is correct
31 Correct 150 ms 6656 KB Output is correct
32 Correct 120 ms 6784 KB Output is correct
33 Correct 100 ms 6656 KB Output is correct
34 Correct 161 ms 6656 KB Output is correct
35 Correct 169 ms 6780 KB Output is correct
36 Correct 71 ms 6656 KB Output is correct
37 Correct 136 ms 6776 KB Output is correct
38 Correct 144 ms 6776 KB Output is correct
39 Correct 119 ms 6656 KB Output is correct
40 Correct 108 ms 6776 KB Output is correct
41 Correct 107 ms 6784 KB Output is correct
42 Correct 109 ms 6656 KB Output is correct
43 Correct 124 ms 6656 KB Output is correct
44 Correct 150 ms 6656 KB Output is correct
45 Correct 178 ms 6780 KB Output is correct
46 Correct 189 ms 6776 KB Output is correct
47 Correct 104 ms 6656 KB Output is correct
48 Correct 114 ms 6656 KB Output is correct
49 Correct 137 ms 6780 KB Output is correct
50 Correct 156 ms 6656 KB Output is correct
51 Correct 106 ms 6656 KB Output is correct
52 Correct 123 ms 6776 KB Output is correct
53 Correct 140 ms 6656 KB Output is correct
54 Correct 170 ms 6776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Execution timed out 2054 ms 16888 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Correct 5 ms 6528 KB Output is correct
4 Correct 5 ms 6528 KB Output is correct
5 Correct 4 ms 6528 KB Output is correct
6 Correct 4 ms 6528 KB Output is correct
7 Correct 5 ms 6528 KB Output is correct
8 Correct 6 ms 6528 KB Output is correct
9 Correct 6 ms 6528 KB Output is correct
10 Correct 6 ms 6528 KB Output is correct
11 Correct 6 ms 6656 KB Output is correct
12 Correct 6 ms 6528 KB Output is correct
13 Correct 5 ms 6528 KB Output is correct
14 Correct 6 ms 6528 KB Output is correct
15 Correct 6 ms 6528 KB Output is correct
16 Correct 6 ms 6528 KB Output is correct
17 Correct 6 ms 6528 KB Output is correct
18 Correct 5 ms 6528 KB Output is correct
19 Correct 6 ms 6528 KB Output is correct
20 Correct 6 ms 6528 KB Output is correct
21 Correct 6 ms 6528 KB Output is correct
22 Correct 6 ms 6528 KB Output is correct
23 Correct 5 ms 6528 KB Output is correct
24 Correct 6 ms 6528 KB Output is correct
25 Correct 7 ms 6528 KB Output is correct
26 Correct 5 ms 6528 KB Output is correct
27 Correct 6 ms 6528 KB Output is correct
28 Correct 6 ms 6528 KB Output is correct
29 Execution timed out 2054 ms 16888 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Correct 5 ms 6528 KB Output is correct
4 Correct 5 ms 6528 KB Output is correct
5 Correct 4 ms 6528 KB Output is correct
6 Correct 4 ms 6528 KB Output is correct
7 Correct 5 ms 6528 KB Output is correct
8 Correct 6 ms 6528 KB Output is correct
9 Correct 6 ms 6528 KB Output is correct
10 Correct 6 ms 6528 KB Output is correct
11 Correct 6 ms 6656 KB Output is correct
12 Correct 6 ms 6528 KB Output is correct
13 Correct 5 ms 6528 KB Output is correct
14 Correct 6 ms 6528 KB Output is correct
15 Correct 6 ms 6528 KB Output is correct
16 Correct 6 ms 6528 KB Output is correct
17 Correct 6 ms 6528 KB Output is correct
18 Correct 5 ms 6528 KB Output is correct
19 Correct 6 ms 6528 KB Output is correct
20 Correct 6 ms 6528 KB Output is correct
21 Correct 6 ms 6528 KB Output is correct
22 Correct 6 ms 6528 KB Output is correct
23 Correct 5 ms 6528 KB Output is correct
24 Correct 6 ms 6528 KB Output is correct
25 Correct 7 ms 6528 KB Output is correct
26 Correct 5 ms 6528 KB Output is correct
27 Correct 6 ms 6528 KB Output is correct
28 Correct 6 ms 6528 KB Output is correct
29 Correct 114 ms 6648 KB Output is correct
30 Correct 155 ms 6656 KB Output is correct
31 Correct 150 ms 6656 KB Output is correct
32 Correct 120 ms 6784 KB Output is correct
33 Correct 100 ms 6656 KB Output is correct
34 Correct 161 ms 6656 KB Output is correct
35 Correct 169 ms 6780 KB Output is correct
36 Correct 71 ms 6656 KB Output is correct
37 Correct 136 ms 6776 KB Output is correct
38 Correct 144 ms 6776 KB Output is correct
39 Correct 119 ms 6656 KB Output is correct
40 Correct 108 ms 6776 KB Output is correct
41 Correct 107 ms 6784 KB Output is correct
42 Correct 109 ms 6656 KB Output is correct
43 Correct 124 ms 6656 KB Output is correct
44 Correct 150 ms 6656 KB Output is correct
45 Correct 178 ms 6780 KB Output is correct
46 Correct 189 ms 6776 KB Output is correct
47 Correct 104 ms 6656 KB Output is correct
48 Correct 114 ms 6656 KB Output is correct
49 Correct 137 ms 6780 KB Output is correct
50 Correct 156 ms 6656 KB Output is correct
51 Correct 106 ms 6656 KB Output is correct
52 Correct 123 ms 6776 KB Output is correct
53 Correct 140 ms 6656 KB Output is correct
54 Correct 170 ms 6776 KB Output is correct
55 Execution timed out 2044 ms 18296 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6656 KB Output is correct
2 Correct 5 ms 6528 KB Output is correct
3 Correct 5 ms 6528 KB Output is correct
4 Correct 5 ms 6528 KB Output is correct
5 Correct 4 ms 6528 KB Output is correct
6 Correct 4 ms 6528 KB Output is correct
7 Correct 5 ms 6528 KB Output is correct
8 Correct 6 ms 6528 KB Output is correct
9 Correct 6 ms 6528 KB Output is correct
10 Correct 6 ms 6528 KB Output is correct
11 Correct 6 ms 6656 KB Output is correct
12 Correct 6 ms 6528 KB Output is correct
13 Correct 5 ms 6528 KB Output is correct
14 Correct 6 ms 6528 KB Output is correct
15 Correct 6 ms 6528 KB Output is correct
16 Correct 6 ms 6528 KB Output is correct
17 Correct 6 ms 6528 KB Output is correct
18 Correct 5 ms 6528 KB Output is correct
19 Correct 6 ms 6528 KB Output is correct
20 Correct 6 ms 6528 KB Output is correct
21 Correct 6 ms 6528 KB Output is correct
22 Correct 6 ms 6528 KB Output is correct
23 Correct 5 ms 6528 KB Output is correct
24 Correct 6 ms 6528 KB Output is correct
25 Correct 7 ms 6528 KB Output is correct
26 Correct 5 ms 6528 KB Output is correct
27 Correct 6 ms 6528 KB Output is correct
28 Correct 6 ms 6528 KB Output is correct
29 Correct 114 ms 6648 KB Output is correct
30 Correct 155 ms 6656 KB Output is correct
31 Correct 150 ms 6656 KB Output is correct
32 Correct 120 ms 6784 KB Output is correct
33 Correct 100 ms 6656 KB Output is correct
34 Correct 161 ms 6656 KB Output is correct
35 Correct 169 ms 6780 KB Output is correct
36 Correct 71 ms 6656 KB Output is correct
37 Correct 136 ms 6776 KB Output is correct
38 Correct 144 ms 6776 KB Output is correct
39 Correct 119 ms 6656 KB Output is correct
40 Correct 108 ms 6776 KB Output is correct
41 Correct 107 ms 6784 KB Output is correct
42 Correct 109 ms 6656 KB Output is correct
43 Correct 124 ms 6656 KB Output is correct
44 Correct 150 ms 6656 KB Output is correct
45 Correct 178 ms 6780 KB Output is correct
46 Correct 189 ms 6776 KB Output is correct
47 Correct 104 ms 6656 KB Output is correct
48 Correct 114 ms 6656 KB Output is correct
49 Correct 137 ms 6780 KB Output is correct
50 Correct 156 ms 6656 KB Output is correct
51 Correct 106 ms 6656 KB Output is correct
52 Correct 123 ms 6776 KB Output is correct
53 Correct 140 ms 6656 KB Output is correct
54 Correct 170 ms 6776 KB Output is correct
55 Execution timed out 2054 ms 16888 KB Time limit exceeded
56 Halted 0 ms 0 KB -