#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;
return;
}
}
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:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%d%d",&a,&b);
| ~~~~~^~~~~~~~~~~~~~
Joker.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%d%d",&l,&r);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8728 KB |
Output is correct |
9 |
Correct |
4 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
4 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 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 |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8472 KB |
Output is correct |
21 |
Correct |
3 ms |
8280 KB |
Output is correct |
22 |
Correct |
3 ms |
8280 KB |
Output is correct |
23 |
Correct |
3 ms |
8476 KB |
Output is correct |
24 |
Correct |
4 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
4 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8728 KB |
Output is correct |
9 |
Correct |
4 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
4 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 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 |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8472 KB |
Output is correct |
21 |
Correct |
3 ms |
8280 KB |
Output is correct |
22 |
Correct |
3 ms |
8280 KB |
Output is correct |
23 |
Correct |
3 ms |
8476 KB |
Output is correct |
24 |
Correct |
4 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
4 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Correct |
51 ms |
8536 KB |
Output is correct |
30 |
Correct |
91 ms |
8536 KB |
Output is correct |
31 |
Correct |
83 ms |
8536 KB |
Output is correct |
32 |
Correct |
63 ms |
8536 KB |
Output is correct |
33 |
Correct |
41 ms |
8536 KB |
Output is correct |
34 |
Correct |
90 ms |
8540 KB |
Output is correct |
35 |
Correct |
103 ms |
8564 KB |
Output is correct |
36 |
Correct |
24 ms |
8572 KB |
Output is correct |
37 |
Correct |
55 ms |
8540 KB |
Output is correct |
38 |
Correct |
46 ms |
8556 KB |
Output is correct |
39 |
Correct |
62 ms |
8532 KB |
Output is correct |
40 |
Correct |
55 ms |
8556 KB |
Output is correct |
41 |
Correct |
56 ms |
8540 KB |
Output is correct |
42 |
Correct |
57 ms |
8568 KB |
Output is correct |
43 |
Correct |
39 ms |
8540 KB |
Output is correct |
44 |
Correct |
66 ms |
8536 KB |
Output is correct |
45 |
Correct |
92 ms |
8540 KB |
Output is correct |
46 |
Correct |
96 ms |
8540 KB |
Output is correct |
47 |
Correct |
52 ms |
8540 KB |
Output is correct |
48 |
Correct |
61 ms |
8472 KB |
Output is correct |
49 |
Correct |
72 ms |
8540 KB |
Output is correct |
50 |
Correct |
100 ms |
8792 KB |
Output is correct |
51 |
Correct |
50 ms |
8536 KB |
Output is correct |
52 |
Correct |
63 ms |
8540 KB |
Output is correct |
53 |
Correct |
77 ms |
8536 KB |
Output is correct |
54 |
Correct |
93 ms |
8536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8728 KB |
Output is correct |
9 |
Correct |
4 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
4 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 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 |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8472 KB |
Output is correct |
21 |
Correct |
3 ms |
8280 KB |
Output is correct |
22 |
Correct |
3 ms |
8280 KB |
Output is correct |
23 |
Correct |
3 ms |
8476 KB |
Output is correct |
24 |
Correct |
4 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
4 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8728 KB |
Output is correct |
9 |
Correct |
4 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
4 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 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 |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8472 KB |
Output is correct |
21 |
Correct |
3 ms |
8280 KB |
Output is correct |
22 |
Correct |
3 ms |
8280 KB |
Output is correct |
23 |
Correct |
3 ms |
8476 KB |
Output is correct |
24 |
Correct |
4 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
4 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Correct |
51 ms |
8536 KB |
Output is correct |
30 |
Correct |
91 ms |
8536 KB |
Output is correct |
31 |
Correct |
83 ms |
8536 KB |
Output is correct |
32 |
Correct |
63 ms |
8536 KB |
Output is correct |
33 |
Correct |
41 ms |
8536 KB |
Output is correct |
34 |
Correct |
90 ms |
8540 KB |
Output is correct |
35 |
Correct |
103 ms |
8564 KB |
Output is correct |
36 |
Correct |
24 ms |
8572 KB |
Output is correct |
37 |
Correct |
55 ms |
8540 KB |
Output is correct |
38 |
Correct |
46 ms |
8556 KB |
Output is correct |
39 |
Correct |
62 ms |
8532 KB |
Output is correct |
40 |
Correct |
55 ms |
8556 KB |
Output is correct |
41 |
Correct |
56 ms |
8540 KB |
Output is correct |
42 |
Correct |
57 ms |
8568 KB |
Output is correct |
43 |
Correct |
39 ms |
8540 KB |
Output is correct |
44 |
Correct |
66 ms |
8536 KB |
Output is correct |
45 |
Correct |
92 ms |
8540 KB |
Output is correct |
46 |
Correct |
96 ms |
8540 KB |
Output is correct |
47 |
Correct |
52 ms |
8540 KB |
Output is correct |
48 |
Correct |
61 ms |
8472 KB |
Output is correct |
49 |
Correct |
72 ms |
8540 KB |
Output is correct |
50 |
Correct |
100 ms |
8792 KB |
Output is correct |
51 |
Correct |
50 ms |
8536 KB |
Output is correct |
52 |
Correct |
63 ms |
8540 KB |
Output is correct |
53 |
Correct |
77 ms |
8536 KB |
Output is correct |
54 |
Correct |
93 ms |
8536 KB |
Output is correct |
55 |
Execution timed out |
2024 ms |
19028 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
3 ms |
8284 KB |
Output is correct |
5 |
Correct |
3 ms |
8284 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
4 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8728 KB |
Output is correct |
9 |
Correct |
4 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8280 KB |
Output is correct |
11 |
Correct |
3 ms |
8284 KB |
Output is correct |
12 |
Correct |
4 ms |
8284 KB |
Output is correct |
13 |
Correct |
3 ms |
8284 KB |
Output is correct |
14 |
Correct |
3 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 |
3 ms |
8284 KB |
Output is correct |
18 |
Correct |
3 ms |
8284 KB |
Output is correct |
19 |
Correct |
4 ms |
8284 KB |
Output is correct |
20 |
Correct |
3 ms |
8472 KB |
Output is correct |
21 |
Correct |
3 ms |
8280 KB |
Output is correct |
22 |
Correct |
3 ms |
8280 KB |
Output is correct |
23 |
Correct |
3 ms |
8476 KB |
Output is correct |
24 |
Correct |
4 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
4 ms |
8280 KB |
Output is correct |
27 |
Correct |
3 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Correct |
51 ms |
8536 KB |
Output is correct |
30 |
Correct |
91 ms |
8536 KB |
Output is correct |
31 |
Correct |
83 ms |
8536 KB |
Output is correct |
32 |
Correct |
63 ms |
8536 KB |
Output is correct |
33 |
Correct |
41 ms |
8536 KB |
Output is correct |
34 |
Correct |
90 ms |
8540 KB |
Output is correct |
35 |
Correct |
103 ms |
8564 KB |
Output is correct |
36 |
Correct |
24 ms |
8572 KB |
Output is correct |
37 |
Correct |
55 ms |
8540 KB |
Output is correct |
38 |
Correct |
46 ms |
8556 KB |
Output is correct |
39 |
Correct |
62 ms |
8532 KB |
Output is correct |
40 |
Correct |
55 ms |
8556 KB |
Output is correct |
41 |
Correct |
56 ms |
8540 KB |
Output is correct |
42 |
Correct |
57 ms |
8568 KB |
Output is correct |
43 |
Correct |
39 ms |
8540 KB |
Output is correct |
44 |
Correct |
66 ms |
8536 KB |
Output is correct |
45 |
Correct |
92 ms |
8540 KB |
Output is correct |
46 |
Correct |
96 ms |
8540 KB |
Output is correct |
47 |
Correct |
52 ms |
8540 KB |
Output is correct |
48 |
Correct |
61 ms |
8472 KB |
Output is correct |
49 |
Correct |
72 ms |
8540 KB |
Output is correct |
50 |
Correct |
100 ms |
8792 KB |
Output is correct |
51 |
Correct |
50 ms |
8536 KB |
Output is correct |
52 |
Correct |
63 ms |
8540 KB |
Output is correct |
53 |
Correct |
77 ms |
8536 KB |
Output is correct |
54 |
Correct |
93 ms |
8536 KB |
Output is correct |
55 |
Incorrect |
2 ms |
8284 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |