# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869023 | 2023-11-03T01:47:49 Z | prohacker | Joker (BOI20_joker) | C++14 | 2000 ms | 7612 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int,int> #define mp make_pair using namespace std; const int N = 2e5+10; const int INF = INT_MAX; const int mod = 1e9+7; int n,m,q; pair<int,int> edges[N]; int color[N],lab[N]; void make_set() { for(int i = 1 ; i <= n ; i++) { lab[i] = i; color[i] = 0; } } pii Find(int u) { if(u == lab[u]) { return pii(u,color[u]); } pii p = Find(lab[u]); lab[u] = p.first; color[u] = (color[u]^p.second); return pii(lab[u],color[u]); } bool join(int u, int v, int c) { pii hihi = Find(u); pii hehe = Find(v); if(hihi.first == hehe.first) { if(hihi.second^hehe.second^c) { return false; } return true; } lab[hehe.first] = hihi.first; color[hehe.first] = (color[u]^color[v]^c); return true; } signed main() { if (fopen("solve.inp", "r")) { freopen("solve.inp", "r", stdin); freopen("solve.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> q; for(int i = 1 ; i <= m ; i++) { int u,v; cin >> u >> v; edges[i] = {u,v}; } while(q--) { int l,r; cin >> l >> r; make_set(); for(int i = 1 ; i < l ; i++) { if(!join(edges[i].first,edges[i].second,1)) { goto done; } } for(int i = r+1 ; i <= m ; i++) { if(!join(edges[i].first,edges[i].second,1)) { goto done; } } cout << "NO" << '\n'; continue; done:; cout << "YES" << '\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2520 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2396 KB | Output is correct |
25 | Correct | 1 ms | 2396 KB | Output is correct |
26 | Correct | 1 ms | 2396 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2520 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2396 KB | Output is correct |
25 | Correct | 1 ms | 2396 KB | Output is correct |
26 | Correct | 1 ms | 2396 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2396 KB | Output is correct |
29 | Correct | 18 ms | 2396 KB | Output is correct |
30 | Correct | 22 ms | 2560 KB | Output is correct |
31 | Correct | 20 ms | 2396 KB | Output is correct |
32 | Correct | 12 ms | 2392 KB | Output is correct |
33 | Correct | 8 ms | 2408 KB | Output is correct |
34 | Correct | 15 ms | 2556 KB | Output is correct |
35 | Correct | 27 ms | 2396 KB | Output is correct |
36 | Correct | 17 ms | 2392 KB | Output is correct |
37 | Correct | 40 ms | 2396 KB | Output is correct |
38 | Correct | 60 ms | 2396 KB | Output is correct |
39 | Correct | 36 ms | 2396 KB | Output is correct |
40 | Correct | 18 ms | 2392 KB | Output is correct |
41 | Correct | 18 ms | 2396 KB | Output is correct |
42 | Correct | 18 ms | 2652 KB | Output is correct |
43 | Correct | 35 ms | 2396 KB | Output is correct |
44 | Correct | 30 ms | 2536 KB | Output is correct |
45 | Correct | 22 ms | 2396 KB | Output is correct |
46 | Correct | 22 ms | 2648 KB | Output is correct |
47 | Correct | 23 ms | 2396 KB | Output is correct |
48 | Correct | 21 ms | 2392 KB | Output is correct |
49 | Correct | 21 ms | 2392 KB | Output is correct |
50 | Correct | 22 ms | 2560 KB | Output is correct |
51 | Correct | 26 ms | 2396 KB | Output is correct |
52 | Correct | 24 ms | 2396 KB | Output is correct |
53 | Correct | 23 ms | 2396 KB | Output is correct |
54 | Correct | 26 ms | 2392 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Execution timed out | 2100 ms | 7496 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2520 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2396 KB | Output is correct |
25 | Correct | 1 ms | 2396 KB | Output is correct |
26 | Correct | 1 ms | 2396 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2396 KB | Output is correct |
29 | Execution timed out | 2100 ms | 7496 KB | Time limit exceeded |
30 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2520 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2396 KB | Output is correct |
25 | Correct | 1 ms | 2396 KB | Output is correct |
26 | Correct | 1 ms | 2396 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2396 KB | Output is correct |
29 | Correct | 18 ms | 2396 KB | Output is correct |
30 | Correct | 22 ms | 2560 KB | Output is correct |
31 | Correct | 20 ms | 2396 KB | Output is correct |
32 | Correct | 12 ms | 2392 KB | Output is correct |
33 | Correct | 8 ms | 2408 KB | Output is correct |
34 | Correct | 15 ms | 2556 KB | Output is correct |
35 | Correct | 27 ms | 2396 KB | Output is correct |
36 | Correct | 17 ms | 2392 KB | Output is correct |
37 | Correct | 40 ms | 2396 KB | Output is correct |
38 | Correct | 60 ms | 2396 KB | Output is correct |
39 | Correct | 36 ms | 2396 KB | Output is correct |
40 | Correct | 18 ms | 2392 KB | Output is correct |
41 | Correct | 18 ms | 2396 KB | Output is correct |
42 | Correct | 18 ms | 2652 KB | Output is correct |
43 | Correct | 35 ms | 2396 KB | Output is correct |
44 | Correct | 30 ms | 2536 KB | Output is correct |
45 | Correct | 22 ms | 2396 KB | Output is correct |
46 | Correct | 22 ms | 2648 KB | Output is correct |
47 | Correct | 23 ms | 2396 KB | Output is correct |
48 | Correct | 21 ms | 2392 KB | Output is correct |
49 | Correct | 21 ms | 2392 KB | Output is correct |
50 | Correct | 22 ms | 2560 KB | Output is correct |
51 | Correct | 26 ms | 2396 KB | Output is correct |
52 | Correct | 24 ms | 2396 KB | Output is correct |
53 | Correct | 23 ms | 2396 KB | Output is correct |
54 | Correct | 26 ms | 2392 KB | Output is correct |
55 | Execution timed out | 2025 ms | 7612 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2520 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2396 KB | Output is correct |
25 | Correct | 1 ms | 2396 KB | Output is correct |
26 | Correct | 1 ms | 2396 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2396 KB | Output is correct |
29 | Correct | 18 ms | 2396 KB | Output is correct |
30 | Correct | 22 ms | 2560 KB | Output is correct |
31 | Correct | 20 ms | 2396 KB | Output is correct |
32 | Correct | 12 ms | 2392 KB | Output is correct |
33 | Correct | 8 ms | 2408 KB | Output is correct |
34 | Correct | 15 ms | 2556 KB | Output is correct |
35 | Correct | 27 ms | 2396 KB | Output is correct |
36 | Correct | 17 ms | 2392 KB | Output is correct |
37 | Correct | 40 ms | 2396 KB | Output is correct |
38 | Correct | 60 ms | 2396 KB | Output is correct |
39 | Correct | 36 ms | 2396 KB | Output is correct |
40 | Correct | 18 ms | 2392 KB | Output is correct |
41 | Correct | 18 ms | 2396 KB | Output is correct |
42 | Correct | 18 ms | 2652 KB | Output is correct |
43 | Correct | 35 ms | 2396 KB | Output is correct |
44 | Correct | 30 ms | 2536 KB | Output is correct |
45 | Correct | 22 ms | 2396 KB | Output is correct |
46 | Correct | 22 ms | 2648 KB | Output is correct |
47 | Correct | 23 ms | 2396 KB | Output is correct |
48 | Correct | 21 ms | 2392 KB | Output is correct |
49 | Correct | 21 ms | 2392 KB | Output is correct |
50 | Correct | 22 ms | 2560 KB | Output is correct |
51 | Correct | 26 ms | 2396 KB | Output is correct |
52 | Correct | 24 ms | 2396 KB | Output is correct |
53 | Correct | 23 ms | 2396 KB | Output is correct |
54 | Correct | 26 ms | 2392 KB | Output is correct |
55 | Execution timed out | 2100 ms | 7496 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |