#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <vector>
using namespace std;
const int N = (1<<18) + 1;
vector<pair<int,int>> nei[N];
int seen[N],h[N];
int cur = 1,l,r;
bool odd;
void dfs(int u,int k = 1){
seen[u] = cur;
h[u] = k;
for (auto [i,j] : nei[u]){
if (j <= r and j >= l)
continue;
if (seen[i] == cur){
if ((h[u] - h[i]) % 2 == 0)
odd = true;
}
else
dfs(i,k+1);
}
}
void sub1(int n,int m,int q){
for (int i=1;i<=m;i++){
int a,b;
scanf("%d%d",&a,&b);
nei[a].push_back({b,i});
nei[b].push_back({a,i});
}
while (q--){
scanf("%d%d",&l,&r);
odd = false;
for (int i=1;i<=n;i++)
if (seen[i]!=cur)
dfs(i);
cur++;
if (odd)
printf("YES\n");
else
printf("NO\n");
}
exit(0);
}
signed main(){
int n,m,q;
cin>>n>>m>>q;
if (min(n,min(m,q)) <= 2000)
sub1(n,m,q);
}
Compilation message
Joker.cpp: In function 'void sub1(int, int, int)':
Joker.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d%d",&a,&b);
| ~~~~~^~~~~~~~~~~~~~
Joker.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d%d",&l,&r);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
8308 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
7 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
4 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8364 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8284 KB |
Output is correct |
22 |
Correct |
4 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8372 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
3 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
4 ms |
8280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
8308 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
7 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
4 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8364 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8284 KB |
Output is correct |
22 |
Correct |
4 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8372 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
3 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
4 ms |
8280 KB |
Output is correct |
29 |
Correct |
53 ms |
8500 KB |
Output is correct |
30 |
Correct |
89 ms |
8540 KB |
Output is correct |
31 |
Correct |
97 ms |
8540 KB |
Output is correct |
32 |
Correct |
79 ms |
8540 KB |
Output is correct |
33 |
Correct |
60 ms |
8540 KB |
Output is correct |
34 |
Correct |
95 ms |
8556 KB |
Output is correct |
35 |
Correct |
97 ms |
8548 KB |
Output is correct |
36 |
Correct |
27 ms |
8536 KB |
Output is correct |
37 |
Correct |
59 ms |
8540 KB |
Output is correct |
38 |
Correct |
58 ms |
8736 KB |
Output is correct |
39 |
Correct |
64 ms |
8572 KB |
Output is correct |
40 |
Correct |
67 ms |
8792 KB |
Output is correct |
41 |
Correct |
65 ms |
8556 KB |
Output is correct |
42 |
Correct |
68 ms |
8564 KB |
Output is correct |
43 |
Correct |
73 ms |
8536 KB |
Output is correct |
44 |
Correct |
85 ms |
8548 KB |
Output is correct |
45 |
Correct |
99 ms |
8792 KB |
Output is correct |
46 |
Correct |
99 ms |
8540 KB |
Output is correct |
47 |
Correct |
63 ms |
8540 KB |
Output is correct |
48 |
Correct |
69 ms |
8548 KB |
Output is correct |
49 |
Correct |
77 ms |
8556 KB |
Output is correct |
50 |
Correct |
86 ms |
8536 KB |
Output is correct |
51 |
Correct |
64 ms |
8536 KB |
Output is correct |
52 |
Correct |
77 ms |
8536 KB |
Output is correct |
53 |
Correct |
83 ms |
8804 KB |
Output is correct |
54 |
Correct |
99 ms |
8560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Incorrect |
3 ms |
8284 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
8308 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
7 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
4 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8364 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8284 KB |
Output is correct |
22 |
Correct |
4 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8372 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
3 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
4 ms |
8280 KB |
Output is correct |
29 |
Incorrect |
3 ms |
8284 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
8308 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
7 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
4 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8364 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8284 KB |
Output is correct |
22 |
Correct |
4 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8372 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
3 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
4 ms |
8280 KB |
Output is correct |
29 |
Correct |
53 ms |
8500 KB |
Output is correct |
30 |
Correct |
89 ms |
8540 KB |
Output is correct |
31 |
Correct |
97 ms |
8540 KB |
Output is correct |
32 |
Correct |
79 ms |
8540 KB |
Output is correct |
33 |
Correct |
60 ms |
8540 KB |
Output is correct |
34 |
Correct |
95 ms |
8556 KB |
Output is correct |
35 |
Correct |
97 ms |
8548 KB |
Output is correct |
36 |
Correct |
27 ms |
8536 KB |
Output is correct |
37 |
Correct |
59 ms |
8540 KB |
Output is correct |
38 |
Correct |
58 ms |
8736 KB |
Output is correct |
39 |
Correct |
64 ms |
8572 KB |
Output is correct |
40 |
Correct |
67 ms |
8792 KB |
Output is correct |
41 |
Correct |
65 ms |
8556 KB |
Output is correct |
42 |
Correct |
68 ms |
8564 KB |
Output is correct |
43 |
Correct |
73 ms |
8536 KB |
Output is correct |
44 |
Correct |
85 ms |
8548 KB |
Output is correct |
45 |
Correct |
99 ms |
8792 KB |
Output is correct |
46 |
Correct |
99 ms |
8540 KB |
Output is correct |
47 |
Correct |
63 ms |
8540 KB |
Output is correct |
48 |
Correct |
69 ms |
8548 KB |
Output is correct |
49 |
Correct |
77 ms |
8556 KB |
Output is correct |
50 |
Correct |
86 ms |
8536 KB |
Output is correct |
51 |
Correct |
64 ms |
8536 KB |
Output is correct |
52 |
Correct |
77 ms |
8536 KB |
Output is correct |
53 |
Correct |
83 ms |
8804 KB |
Output is correct |
54 |
Correct |
99 ms |
8560 KB |
Output is correct |
55 |
Execution timed out |
2007 ms |
19024 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8280 KB |
Output is correct |
2 |
Correct |
4 ms |
8284 KB |
Output is correct |
3 |
Correct |
4 ms |
8308 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
7 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
9 |
Correct |
3 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
3 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
4 ms |
8284 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
3 ms |
8284 KB |
Output is correct |
17 |
Correct |
4 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8364 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8284 KB |
Output is correct |
21 |
Correct |
3 ms |
8284 KB |
Output is correct |
22 |
Correct |
4 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8372 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
3 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
4 ms |
8280 KB |
Output is correct |
29 |
Correct |
53 ms |
8500 KB |
Output is correct |
30 |
Correct |
89 ms |
8540 KB |
Output is correct |
31 |
Correct |
97 ms |
8540 KB |
Output is correct |
32 |
Correct |
79 ms |
8540 KB |
Output is correct |
33 |
Correct |
60 ms |
8540 KB |
Output is correct |
34 |
Correct |
95 ms |
8556 KB |
Output is correct |
35 |
Correct |
97 ms |
8548 KB |
Output is correct |
36 |
Correct |
27 ms |
8536 KB |
Output is correct |
37 |
Correct |
59 ms |
8540 KB |
Output is correct |
38 |
Correct |
58 ms |
8736 KB |
Output is correct |
39 |
Correct |
64 ms |
8572 KB |
Output is correct |
40 |
Correct |
67 ms |
8792 KB |
Output is correct |
41 |
Correct |
65 ms |
8556 KB |
Output is correct |
42 |
Correct |
68 ms |
8564 KB |
Output is correct |
43 |
Correct |
73 ms |
8536 KB |
Output is correct |
44 |
Correct |
85 ms |
8548 KB |
Output is correct |
45 |
Correct |
99 ms |
8792 KB |
Output is correct |
46 |
Correct |
99 ms |
8540 KB |
Output is correct |
47 |
Correct |
63 ms |
8540 KB |
Output is correct |
48 |
Correct |
69 ms |
8548 KB |
Output is correct |
49 |
Correct |
77 ms |
8556 KB |
Output is correct |
50 |
Correct |
86 ms |
8536 KB |
Output is correct |
51 |
Correct |
64 ms |
8536 KB |
Output is correct |
52 |
Correct |
77 ms |
8536 KB |
Output is correct |
53 |
Correct |
83 ms |
8804 KB |
Output is correct |
54 |
Correct |
99 ms |
8560 KB |
Output is correct |
55 |
Incorrect |
3 ms |
8284 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |