#include <bits/stdc++.h>
using namespace std;
int const N=2e5+5;
vector<int> adj[N];
bool dep[N];
int rep[N];
vector<int> com[N];
// int dp[N][N];
bool merge(int a,int b){
int ra=a;
int rb=b;
a=rep[a];
b=rep[b];
// cout<<ra<<' '<<rb<<endl;
if(a==b){
if(dep[ra]==dep[rb])
return 0;
return 1;
}
if(com[a].size()>com[b].size()){
swap(a,b);
swap(ra,rb);
}
bool sw=0;
if(dep[ra]==dep[rb])
sw=1;
for(auto i:com[a]){
com[b].push_back(i);
rep[i]=b;
dep[i]^=sw;
}
com[a].clear();
return 1;
}
int main()
{
int n,m,q;
cin>>n>>m>>q;
vector<pair<int,int>> edge;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
if(a>b)
swap(a,b);
edge.push_back({a,b});
}
// cout<<k<<endl;
for(int i=0;i<q;i++){
for(int i=1;i<=n;i++){
rep[i]=i;
com[i].clear();
com[i].push_back(i);
}
int l,r;
cin>>l>>r;
l--;
r--;
string ans="NO";
for(int i=0;i<m;i++){
if(l<=i && i<=r)
continue;
if(merge(edge[i].first,edge[i].second)==0){
ans="YES";
break;
}
}
cout<<ans<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
10588 KB |
Output is correct |
5 |
Correct |
4 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
10588 KB |
Output is correct |
8 |
Correct |
5 ms |
10752 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
4 ms |
10584 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
5 ms |
10812 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
4 ms |
10844 KB |
Output is correct |
15 |
Correct |
5 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
4 ms |
10796 KB |
Output is correct |
20 |
Correct |
4 ms |
10588 KB |
Output is correct |
21 |
Correct |
4 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
4 ms |
10588 KB |
Output is correct |
27 |
Correct |
4 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
10588 KB |
Output is correct |
5 |
Correct |
4 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
10588 KB |
Output is correct |
8 |
Correct |
5 ms |
10752 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
4 ms |
10584 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
5 ms |
10812 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
4 ms |
10844 KB |
Output is correct |
15 |
Correct |
5 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
4 ms |
10796 KB |
Output is correct |
20 |
Correct |
4 ms |
10588 KB |
Output is correct |
21 |
Correct |
4 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
4 ms |
10588 KB |
Output is correct |
27 |
Correct |
4 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
29 |
Correct |
46 ms |
10912 KB |
Output is correct |
30 |
Correct |
55 ms |
10988 KB |
Output is correct |
31 |
Correct |
47 ms |
11000 KB |
Output is correct |
32 |
Correct |
29 ms |
10928 KB |
Output is correct |
33 |
Correct |
20 ms |
10844 KB |
Output is correct |
34 |
Correct |
42 ms |
11004 KB |
Output is correct |
35 |
Correct |
62 ms |
11068 KB |
Output is correct |
36 |
Correct |
39 ms |
11096 KB |
Output is correct |
37 |
Correct |
79 ms |
13136 KB |
Output is correct |
38 |
Correct |
82 ms |
12128 KB |
Output is correct |
39 |
Correct |
62 ms |
11456 KB |
Output is correct |
40 |
Correct |
40 ms |
10844 KB |
Output is correct |
41 |
Correct |
45 ms |
10844 KB |
Output is correct |
42 |
Correct |
39 ms |
10844 KB |
Output is correct |
43 |
Correct |
28 ms |
10844 KB |
Output is correct |
44 |
Correct |
45 ms |
10992 KB |
Output is correct |
45 |
Correct |
44 ms |
10840 KB |
Output is correct |
46 |
Correct |
54 ms |
10844 KB |
Output is correct |
47 |
Correct |
33 ms |
10816 KB |
Output is correct |
48 |
Correct |
37 ms |
10996 KB |
Output is correct |
49 |
Correct |
46 ms |
10912 KB |
Output is correct |
50 |
Correct |
56 ms |
10844 KB |
Output is correct |
51 |
Correct |
31 ms |
10980 KB |
Output is correct |
52 |
Correct |
38 ms |
10992 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
59 ms |
11036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Execution timed out |
2057 ms |
120284 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
10588 KB |
Output is correct |
5 |
Correct |
4 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
10588 KB |
Output is correct |
8 |
Correct |
5 ms |
10752 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
4 ms |
10584 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
5 ms |
10812 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
4 ms |
10844 KB |
Output is correct |
15 |
Correct |
5 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
4 ms |
10796 KB |
Output is correct |
20 |
Correct |
4 ms |
10588 KB |
Output is correct |
21 |
Correct |
4 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
4 ms |
10588 KB |
Output is correct |
27 |
Correct |
4 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
29 |
Execution timed out |
2057 ms |
120284 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
10588 KB |
Output is correct |
5 |
Correct |
4 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
10588 KB |
Output is correct |
8 |
Correct |
5 ms |
10752 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
4 ms |
10584 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
5 ms |
10812 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
4 ms |
10844 KB |
Output is correct |
15 |
Correct |
5 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
4 ms |
10796 KB |
Output is correct |
20 |
Correct |
4 ms |
10588 KB |
Output is correct |
21 |
Correct |
4 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
4 ms |
10588 KB |
Output is correct |
27 |
Correct |
4 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
29 |
Correct |
46 ms |
10912 KB |
Output is correct |
30 |
Correct |
55 ms |
10988 KB |
Output is correct |
31 |
Correct |
47 ms |
11000 KB |
Output is correct |
32 |
Correct |
29 ms |
10928 KB |
Output is correct |
33 |
Correct |
20 ms |
10844 KB |
Output is correct |
34 |
Correct |
42 ms |
11004 KB |
Output is correct |
35 |
Correct |
62 ms |
11068 KB |
Output is correct |
36 |
Correct |
39 ms |
11096 KB |
Output is correct |
37 |
Correct |
79 ms |
13136 KB |
Output is correct |
38 |
Correct |
82 ms |
12128 KB |
Output is correct |
39 |
Correct |
62 ms |
11456 KB |
Output is correct |
40 |
Correct |
40 ms |
10844 KB |
Output is correct |
41 |
Correct |
45 ms |
10844 KB |
Output is correct |
42 |
Correct |
39 ms |
10844 KB |
Output is correct |
43 |
Correct |
28 ms |
10844 KB |
Output is correct |
44 |
Correct |
45 ms |
10992 KB |
Output is correct |
45 |
Correct |
44 ms |
10840 KB |
Output is correct |
46 |
Correct |
54 ms |
10844 KB |
Output is correct |
47 |
Correct |
33 ms |
10816 KB |
Output is correct |
48 |
Correct |
37 ms |
10996 KB |
Output is correct |
49 |
Correct |
46 ms |
10912 KB |
Output is correct |
50 |
Correct |
56 ms |
10844 KB |
Output is correct |
51 |
Correct |
31 ms |
10980 KB |
Output is correct |
52 |
Correct |
38 ms |
10992 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
59 ms |
11036 KB |
Output is correct |
55 |
Execution timed out |
2009 ms |
64504 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
10588 KB |
Output is correct |
2 |
Correct |
3 ms |
10588 KB |
Output is correct |
3 |
Correct |
3 ms |
10588 KB |
Output is correct |
4 |
Correct |
4 ms |
10588 KB |
Output is correct |
5 |
Correct |
4 ms |
10588 KB |
Output is correct |
6 |
Correct |
3 ms |
10588 KB |
Output is correct |
7 |
Correct |
3 ms |
10588 KB |
Output is correct |
8 |
Correct |
5 ms |
10752 KB |
Output is correct |
9 |
Correct |
4 ms |
10588 KB |
Output is correct |
10 |
Correct |
4 ms |
10584 KB |
Output is correct |
11 |
Correct |
4 ms |
10840 KB |
Output is correct |
12 |
Correct |
5 ms |
10812 KB |
Output is correct |
13 |
Correct |
3 ms |
10588 KB |
Output is correct |
14 |
Correct |
4 ms |
10844 KB |
Output is correct |
15 |
Correct |
5 ms |
10588 KB |
Output is correct |
16 |
Correct |
3 ms |
10588 KB |
Output is correct |
17 |
Correct |
3 ms |
10588 KB |
Output is correct |
18 |
Correct |
3 ms |
10588 KB |
Output is correct |
19 |
Correct |
4 ms |
10796 KB |
Output is correct |
20 |
Correct |
4 ms |
10588 KB |
Output is correct |
21 |
Correct |
4 ms |
10588 KB |
Output is correct |
22 |
Correct |
3 ms |
10588 KB |
Output is correct |
23 |
Correct |
4 ms |
10588 KB |
Output is correct |
24 |
Correct |
4 ms |
10588 KB |
Output is correct |
25 |
Correct |
4 ms |
10588 KB |
Output is correct |
26 |
Correct |
4 ms |
10588 KB |
Output is correct |
27 |
Correct |
4 ms |
10588 KB |
Output is correct |
28 |
Correct |
4 ms |
10588 KB |
Output is correct |
29 |
Correct |
46 ms |
10912 KB |
Output is correct |
30 |
Correct |
55 ms |
10988 KB |
Output is correct |
31 |
Correct |
47 ms |
11000 KB |
Output is correct |
32 |
Correct |
29 ms |
10928 KB |
Output is correct |
33 |
Correct |
20 ms |
10844 KB |
Output is correct |
34 |
Correct |
42 ms |
11004 KB |
Output is correct |
35 |
Correct |
62 ms |
11068 KB |
Output is correct |
36 |
Correct |
39 ms |
11096 KB |
Output is correct |
37 |
Correct |
79 ms |
13136 KB |
Output is correct |
38 |
Correct |
82 ms |
12128 KB |
Output is correct |
39 |
Correct |
62 ms |
11456 KB |
Output is correct |
40 |
Correct |
40 ms |
10844 KB |
Output is correct |
41 |
Correct |
45 ms |
10844 KB |
Output is correct |
42 |
Correct |
39 ms |
10844 KB |
Output is correct |
43 |
Correct |
28 ms |
10844 KB |
Output is correct |
44 |
Correct |
45 ms |
10992 KB |
Output is correct |
45 |
Correct |
44 ms |
10840 KB |
Output is correct |
46 |
Correct |
54 ms |
10844 KB |
Output is correct |
47 |
Correct |
33 ms |
10816 KB |
Output is correct |
48 |
Correct |
37 ms |
10996 KB |
Output is correct |
49 |
Correct |
46 ms |
10912 KB |
Output is correct |
50 |
Correct |
56 ms |
10844 KB |
Output is correct |
51 |
Correct |
31 ms |
10980 KB |
Output is correct |
52 |
Correct |
38 ms |
10992 KB |
Output is correct |
53 |
Correct |
47 ms |
10844 KB |
Output is correct |
54 |
Correct |
59 ms |
11036 KB |
Output is correct |
55 |
Execution timed out |
2057 ms |
120284 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |