#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> p32;
typedef vector<p32> vp32;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
int main(){
int n,m,q; cin>>n>>m>>q;
vp32 adj[n];
for(int i = 0; i<m; i++){
int a,b; cin>>a>>b;
a--; b--;
adj[a].eb(b,i+1);
adj[b].eb(a,i+1);
}
for(int j = 0; j<q; j++){
int l,r; cin>>l>>r;
int parent[n];
int depth[n];
memset(parent,0,sizeof parent);
memset(depth,0,sizeof depth);
stack<int> qu;
for(int i = 0; i<n; i++){
if(!parent[i]){
parent[i] = i+1;
qu.push(i);
while(!qu.empty()){
int x = qu.top();
depth[x] = depth[parent[x]-1]+1;
qu.pop();
for(p32 tt : adj[x]){
if(tt.se<l||tt.se>r){
if(depth[tt.fi]&&parent[x]-1!=tt.fi&&((depth[x]-depth[tt.fi]+1)&1)) goto found;
if(parent[tt.fi]==0){
parent[tt.fi] = x+1;
qu.push(tt.fi);
}
}
}
}
}
}
cout<<"NO\n";
continue;
found:
cout<<"YES\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
49 ms |
348 KB |
Output is correct |
30 |
Correct |
54 ms |
604 KB |
Output is correct |
31 |
Correct |
47 ms |
348 KB |
Output is correct |
32 |
Correct |
37 ms |
348 KB |
Output is correct |
33 |
Correct |
27 ms |
348 KB |
Output is correct |
34 |
Correct |
40 ms |
604 KB |
Output is correct |
35 |
Correct |
63 ms |
348 KB |
Output is correct |
36 |
Correct |
21 ms |
348 KB |
Output is correct |
37 |
Correct |
55 ms |
604 KB |
Output is correct |
38 |
Correct |
55 ms |
448 KB |
Output is correct |
39 |
Correct |
48 ms |
348 KB |
Output is correct |
40 |
Correct |
33 ms |
580 KB |
Output is correct |
41 |
Correct |
39 ms |
348 KB |
Output is correct |
42 |
Correct |
35 ms |
348 KB |
Output is correct |
43 |
Correct |
21 ms |
348 KB |
Output is correct |
44 |
Correct |
25 ms |
348 KB |
Output is correct |
45 |
Correct |
35 ms |
348 KB |
Output is correct |
46 |
Correct |
42 ms |
604 KB |
Output is correct |
47 |
Correct |
34 ms |
348 KB |
Output is correct |
48 |
Correct |
35 ms |
348 KB |
Output is correct |
49 |
Correct |
42 ms |
348 KB |
Output is correct |
50 |
Correct |
44 ms |
604 KB |
Output is correct |
51 |
Correct |
37 ms |
348 KB |
Output is correct |
52 |
Correct |
45 ms |
348 KB |
Output is correct |
53 |
Correct |
49 ms |
348 KB |
Output is correct |
54 |
Correct |
59 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
2036 ms |
9816 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Execution timed out |
2036 ms |
9816 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
49 ms |
348 KB |
Output is correct |
30 |
Correct |
54 ms |
604 KB |
Output is correct |
31 |
Correct |
47 ms |
348 KB |
Output is correct |
32 |
Correct |
37 ms |
348 KB |
Output is correct |
33 |
Correct |
27 ms |
348 KB |
Output is correct |
34 |
Correct |
40 ms |
604 KB |
Output is correct |
35 |
Correct |
63 ms |
348 KB |
Output is correct |
36 |
Correct |
21 ms |
348 KB |
Output is correct |
37 |
Correct |
55 ms |
604 KB |
Output is correct |
38 |
Correct |
55 ms |
448 KB |
Output is correct |
39 |
Correct |
48 ms |
348 KB |
Output is correct |
40 |
Correct |
33 ms |
580 KB |
Output is correct |
41 |
Correct |
39 ms |
348 KB |
Output is correct |
42 |
Correct |
35 ms |
348 KB |
Output is correct |
43 |
Correct |
21 ms |
348 KB |
Output is correct |
44 |
Correct |
25 ms |
348 KB |
Output is correct |
45 |
Correct |
35 ms |
348 KB |
Output is correct |
46 |
Correct |
42 ms |
604 KB |
Output is correct |
47 |
Correct |
34 ms |
348 KB |
Output is correct |
48 |
Correct |
35 ms |
348 KB |
Output is correct |
49 |
Correct |
42 ms |
348 KB |
Output is correct |
50 |
Correct |
44 ms |
604 KB |
Output is correct |
51 |
Correct |
37 ms |
348 KB |
Output is correct |
52 |
Correct |
45 ms |
348 KB |
Output is correct |
53 |
Correct |
49 ms |
348 KB |
Output is correct |
54 |
Correct |
59 ms |
604 KB |
Output is correct |
55 |
Execution timed out |
2020 ms |
10832 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
49 ms |
348 KB |
Output is correct |
30 |
Correct |
54 ms |
604 KB |
Output is correct |
31 |
Correct |
47 ms |
348 KB |
Output is correct |
32 |
Correct |
37 ms |
348 KB |
Output is correct |
33 |
Correct |
27 ms |
348 KB |
Output is correct |
34 |
Correct |
40 ms |
604 KB |
Output is correct |
35 |
Correct |
63 ms |
348 KB |
Output is correct |
36 |
Correct |
21 ms |
348 KB |
Output is correct |
37 |
Correct |
55 ms |
604 KB |
Output is correct |
38 |
Correct |
55 ms |
448 KB |
Output is correct |
39 |
Correct |
48 ms |
348 KB |
Output is correct |
40 |
Correct |
33 ms |
580 KB |
Output is correct |
41 |
Correct |
39 ms |
348 KB |
Output is correct |
42 |
Correct |
35 ms |
348 KB |
Output is correct |
43 |
Correct |
21 ms |
348 KB |
Output is correct |
44 |
Correct |
25 ms |
348 KB |
Output is correct |
45 |
Correct |
35 ms |
348 KB |
Output is correct |
46 |
Correct |
42 ms |
604 KB |
Output is correct |
47 |
Correct |
34 ms |
348 KB |
Output is correct |
48 |
Correct |
35 ms |
348 KB |
Output is correct |
49 |
Correct |
42 ms |
348 KB |
Output is correct |
50 |
Correct |
44 ms |
604 KB |
Output is correct |
51 |
Correct |
37 ms |
348 KB |
Output is correct |
52 |
Correct |
45 ms |
348 KB |
Output is correct |
53 |
Correct |
49 ms |
348 KB |
Output is correct |
54 |
Correct |
59 ms |
604 KB |
Output is correct |
55 |
Execution timed out |
2036 ms |
9816 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |