#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
#define y1 YONE
#define free freeee
#define lcm llcm
/*
⠄⠄⠄⠄⢠⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣯⢻⣿⣿⣿⣿⣆⠄⠄⠄
⠄⠄⣼⢀⣿⣿⣿⣿⣏⡏⠄⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢻⣿⣿⣿⣿⡆⠄⠄
⠄⠄⡟⣼⣿⣿⣿⣿⣿⠄⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⣿⣇⢻⣿⣿⣿⣿⠄⠄
⠄⢰⠃⣿⣿⠿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠙⠿⣿⣿⣿⣿⣿⠄⢿⣿⣿⣿⡄⠄
⠄⢸⢠⣿⣿⣧⡙⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠈⠛⢿⣿⣿⡇⠸⣿⡿⣸⡇⠄
⠄⠈⡆⣿⣿⣿⣿⣦⡙⠳⠄⠄⠄⠄⠄⠄⢀⣠⣤⣀⣈⠙⠃⠄⠿⢇⣿⡇⠄
⠄⠄⡇⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⣠⣶⣿⣿⣿⣿⣿⣿⣷⣆⡀⣼⣿⡇⠄
⠄⠄⢹⡘⣿⣿⣿⢿⣷⡀⠄⢀⣴⣾⣟⠉⠉⠉⠉⣽⣿⣿⣿⣿⠇⢹⣿⠃⠄
⠄⠄⠄⢷⡘⢿⣿⣎⢻⣷⠰⣿⣿⣿⣿⣦⣀⣀⣴⣿⣿⣿⠟⢫⡾⢸⡟⠄.
⠄⠄⠄⠄⠻⣦⡙⠿⣧⠙⢷⠙⠻⠿⢿⡿⠿⠿⠛⠋⠉⠄⠂⠘⠁⠞⠄⠄⠄
⠄⠄⠄⠄⠄⠈⠙⠑⣠⣤⣴⡖⠄⠿⣋⣉⣉⡁⠄⢾⣦⠄⠄⠄⠄⠄⠄⠄⠄
*/
typedef unsigned long long ull;
using namespace std;
const int N=1e5+5;
int n,m,q,tin[N],t,l,r;
vector<pair<int,int>> adj[N];
bool cyc,vis[N];
void dfs(int x,int p){
vis[x]=1;
tin[x]=++t;
for (auto u:adj[x]){
if (u.F==p || (u.S>=l && u.S<=r)) continue;
if (vis[u.F]) cyc|=((tin[x]-tin[u.F]+1)&1);
else dfs(u.F,x);
if (cyc) break;
}t--;
return;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m>>q;
for (int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
adj[x].pb({y,i});
adj[y].pb({x,i});
}
while (q--){
cin>>l>>r;
memset(vis,0,sizeof(vis));cyc=0;
for (int i=1;i<=n;i++){
if (vis[i]) continue;
dfs(i,0);
if (cyc) break;
}
if (cyc) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2816 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2912 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
2 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
2916 KB |
Output is correct |
14 |
Correct |
2 ms |
2908 KB |
Output is correct |
15 |
Correct |
2 ms |
2908 KB |
Output is correct |
16 |
Correct |
2 ms |
2812 KB |
Output is correct |
17 |
Correct |
1 ms |
2712 KB |
Output is correct |
18 |
Correct |
2 ms |
2912 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2908 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2904 KB |
Output is correct |
26 |
Correct |
1 ms |
2904 KB |
Output is correct |
27 |
Correct |
1 ms |
2812 KB |
Output is correct |
28 |
Correct |
1 ms |
2820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2816 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2912 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
2 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
2916 KB |
Output is correct |
14 |
Correct |
2 ms |
2908 KB |
Output is correct |
15 |
Correct |
2 ms |
2908 KB |
Output is correct |
16 |
Correct |
2 ms |
2812 KB |
Output is correct |
17 |
Correct |
1 ms |
2712 KB |
Output is correct |
18 |
Correct |
2 ms |
2912 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2908 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2904 KB |
Output is correct |
26 |
Correct |
1 ms |
2904 KB |
Output is correct |
27 |
Correct |
1 ms |
2812 KB |
Output is correct |
28 |
Correct |
1 ms |
2820 KB |
Output is correct |
29 |
Correct |
56 ms |
2908 KB |
Output is correct |
30 |
Correct |
41 ms |
2904 KB |
Output is correct |
31 |
Correct |
31 ms |
3036 KB |
Output is correct |
32 |
Correct |
16 ms |
2904 KB |
Output is correct |
33 |
Correct |
8 ms |
2908 KB |
Output is correct |
34 |
Correct |
29 ms |
2904 KB |
Output is correct |
35 |
Correct |
46 ms |
2908 KB |
Output is correct |
36 |
Correct |
15 ms |
2908 KB |
Output is correct |
37 |
Correct |
51 ms |
2904 KB |
Output is correct |
38 |
Correct |
50 ms |
2908 KB |
Output is correct |
39 |
Correct |
42 ms |
3008 KB |
Output is correct |
40 |
Correct |
18 ms |
2908 KB |
Output is correct |
41 |
Correct |
18 ms |
2908 KB |
Output is correct |
42 |
Correct |
18 ms |
2908 KB |
Output is correct |
43 |
Correct |
7 ms |
2828 KB |
Output is correct |
44 |
Correct |
6 ms |
2904 KB |
Output is correct |
45 |
Correct |
9 ms |
2908 KB |
Output is correct |
46 |
Correct |
12 ms |
2904 KB |
Output is correct |
47 |
Correct |
19 ms |
2904 KB |
Output is correct |
48 |
Correct |
22 ms |
2908 KB |
Output is correct |
49 |
Correct |
29 ms |
2824 KB |
Output is correct |
50 |
Correct |
40 ms |
3008 KB |
Output is correct |
51 |
Correct |
21 ms |
2904 KB |
Output is correct |
52 |
Correct |
24 ms |
2908 KB |
Output is correct |
53 |
Correct |
31 ms |
3040 KB |
Output is correct |
54 |
Correct |
44 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Execution timed out |
2063 ms |
15876 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2816 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2912 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
2 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
2916 KB |
Output is correct |
14 |
Correct |
2 ms |
2908 KB |
Output is correct |
15 |
Correct |
2 ms |
2908 KB |
Output is correct |
16 |
Correct |
2 ms |
2812 KB |
Output is correct |
17 |
Correct |
1 ms |
2712 KB |
Output is correct |
18 |
Correct |
2 ms |
2912 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2908 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2904 KB |
Output is correct |
26 |
Correct |
1 ms |
2904 KB |
Output is correct |
27 |
Correct |
1 ms |
2812 KB |
Output is correct |
28 |
Correct |
1 ms |
2820 KB |
Output is correct |
29 |
Execution timed out |
2063 ms |
15876 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2816 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2912 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
2 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
2916 KB |
Output is correct |
14 |
Correct |
2 ms |
2908 KB |
Output is correct |
15 |
Correct |
2 ms |
2908 KB |
Output is correct |
16 |
Correct |
2 ms |
2812 KB |
Output is correct |
17 |
Correct |
1 ms |
2712 KB |
Output is correct |
18 |
Correct |
2 ms |
2912 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2908 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2904 KB |
Output is correct |
26 |
Correct |
1 ms |
2904 KB |
Output is correct |
27 |
Correct |
1 ms |
2812 KB |
Output is correct |
28 |
Correct |
1 ms |
2820 KB |
Output is correct |
29 |
Correct |
56 ms |
2908 KB |
Output is correct |
30 |
Correct |
41 ms |
2904 KB |
Output is correct |
31 |
Correct |
31 ms |
3036 KB |
Output is correct |
32 |
Correct |
16 ms |
2904 KB |
Output is correct |
33 |
Correct |
8 ms |
2908 KB |
Output is correct |
34 |
Correct |
29 ms |
2904 KB |
Output is correct |
35 |
Correct |
46 ms |
2908 KB |
Output is correct |
36 |
Correct |
15 ms |
2908 KB |
Output is correct |
37 |
Correct |
51 ms |
2904 KB |
Output is correct |
38 |
Correct |
50 ms |
2908 KB |
Output is correct |
39 |
Correct |
42 ms |
3008 KB |
Output is correct |
40 |
Correct |
18 ms |
2908 KB |
Output is correct |
41 |
Correct |
18 ms |
2908 KB |
Output is correct |
42 |
Correct |
18 ms |
2908 KB |
Output is correct |
43 |
Correct |
7 ms |
2828 KB |
Output is correct |
44 |
Correct |
6 ms |
2904 KB |
Output is correct |
45 |
Correct |
9 ms |
2908 KB |
Output is correct |
46 |
Correct |
12 ms |
2904 KB |
Output is correct |
47 |
Correct |
19 ms |
2904 KB |
Output is correct |
48 |
Correct |
22 ms |
2908 KB |
Output is correct |
49 |
Correct |
29 ms |
2824 KB |
Output is correct |
50 |
Correct |
40 ms |
3008 KB |
Output is correct |
51 |
Correct |
21 ms |
2904 KB |
Output is correct |
52 |
Correct |
24 ms |
2908 KB |
Output is correct |
53 |
Correct |
31 ms |
3040 KB |
Output is correct |
54 |
Correct |
44 ms |
2908 KB |
Output is correct |
55 |
Execution timed out |
2021 ms |
17396 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2816 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2912 KB |
Output is correct |
7 |
Correct |
2 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2904 KB |
Output is correct |
10 |
Correct |
2 ms |
2904 KB |
Output is correct |
11 |
Correct |
2 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
2916 KB |
Output is correct |
14 |
Correct |
2 ms |
2908 KB |
Output is correct |
15 |
Correct |
2 ms |
2908 KB |
Output is correct |
16 |
Correct |
2 ms |
2812 KB |
Output is correct |
17 |
Correct |
1 ms |
2712 KB |
Output is correct |
18 |
Correct |
2 ms |
2912 KB |
Output is correct |
19 |
Correct |
2 ms |
2908 KB |
Output is correct |
20 |
Correct |
1 ms |
2908 KB |
Output is correct |
21 |
Correct |
1 ms |
2908 KB |
Output is correct |
22 |
Correct |
1 ms |
2908 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2904 KB |
Output is correct |
26 |
Correct |
1 ms |
2904 KB |
Output is correct |
27 |
Correct |
1 ms |
2812 KB |
Output is correct |
28 |
Correct |
1 ms |
2820 KB |
Output is correct |
29 |
Correct |
56 ms |
2908 KB |
Output is correct |
30 |
Correct |
41 ms |
2904 KB |
Output is correct |
31 |
Correct |
31 ms |
3036 KB |
Output is correct |
32 |
Correct |
16 ms |
2904 KB |
Output is correct |
33 |
Correct |
8 ms |
2908 KB |
Output is correct |
34 |
Correct |
29 ms |
2904 KB |
Output is correct |
35 |
Correct |
46 ms |
2908 KB |
Output is correct |
36 |
Correct |
15 ms |
2908 KB |
Output is correct |
37 |
Correct |
51 ms |
2904 KB |
Output is correct |
38 |
Correct |
50 ms |
2908 KB |
Output is correct |
39 |
Correct |
42 ms |
3008 KB |
Output is correct |
40 |
Correct |
18 ms |
2908 KB |
Output is correct |
41 |
Correct |
18 ms |
2908 KB |
Output is correct |
42 |
Correct |
18 ms |
2908 KB |
Output is correct |
43 |
Correct |
7 ms |
2828 KB |
Output is correct |
44 |
Correct |
6 ms |
2904 KB |
Output is correct |
45 |
Correct |
9 ms |
2908 KB |
Output is correct |
46 |
Correct |
12 ms |
2904 KB |
Output is correct |
47 |
Correct |
19 ms |
2904 KB |
Output is correct |
48 |
Correct |
22 ms |
2908 KB |
Output is correct |
49 |
Correct |
29 ms |
2824 KB |
Output is correct |
50 |
Correct |
40 ms |
3008 KB |
Output is correct |
51 |
Correct |
21 ms |
2904 KB |
Output is correct |
52 |
Correct |
24 ms |
2908 KB |
Output is correct |
53 |
Correct |
31 ms |
3040 KB |
Output is correct |
54 |
Correct |
44 ms |
2908 KB |
Output is correct |
55 |
Execution timed out |
2063 ms |
15876 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |