/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;
int n, m, q, pos[N];
bool ok;
vector<int> path;
vector<pair<int, int>> g[N];
vector<bool> vis, edg(N);
void dfs(int v, int p){
vis[v] = 1;
path.pb(v);
pos[v] = path.size();
for(auto k: g[v]){
int u = k.first;
if(edg[k.second]) continue;
if(u != p){
if(vis[u]){
if(pos[v] % 2 == pos[u] % 2){
ok = 1;
}
}
else
dfs(u, v);
}
}
path.pop_back();
}
void solve(){
cin >> n >> m >> q;
for(int i = 0; i < m; ++i){
int u, v; cin >> u >> v;
g[u].pb({v, i + 1});
g[v].pb({u, i + 1});
}
for(int i = 0; i < q; ++i){
int l, r; cin >> l >> r;
for(int j = 1; j <= m; ++j) edg[j] = (l <= j && j <= r);
vis.clear();
vis.resize(n+1);
ok = 0;
for(int v = 1; v <= n; ++v) if(!vis[v]) dfs(v, v);
if(ok) cout << "YES\n";
else cout << "NO\n";
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int T = 1, aa;
// cin >> T;aa=T;
while(T--){
// cout << "Case #" << aa-T << ": ";
solve();
cout << '\n';
}
return 0;
}
Compilation message
Joker.cpp: In function 'int main()':
Joker.cpp:68:16: warning: unused variable 'aa' [-Wunused-variable]
68 | int T = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Correct |
15 ms |
23936 KB |
Output is correct |
4 |
Correct |
13 ms |
23892 KB |
Output is correct |
5 |
Correct |
15 ms |
23892 KB |
Output is correct |
6 |
Correct |
13 ms |
23892 KB |
Output is correct |
7 |
Correct |
12 ms |
23868 KB |
Output is correct |
8 |
Correct |
14 ms |
23944 KB |
Output is correct |
9 |
Correct |
15 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23940 KB |
Output is correct |
11 |
Correct |
15 ms |
23892 KB |
Output is correct |
12 |
Correct |
14 ms |
23824 KB |
Output is correct |
13 |
Correct |
12 ms |
23940 KB |
Output is correct |
14 |
Correct |
13 ms |
23892 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
14 ms |
23892 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23856 KB |
Output is correct |
20 |
Correct |
15 ms |
23892 KB |
Output is correct |
21 |
Correct |
13 ms |
23892 KB |
Output is correct |
22 |
Correct |
14 ms |
23944 KB |
Output is correct |
23 |
Correct |
14 ms |
23940 KB |
Output is correct |
24 |
Correct |
13 ms |
23936 KB |
Output is correct |
25 |
Correct |
13 ms |
23832 KB |
Output is correct |
26 |
Correct |
15 ms |
23892 KB |
Output is correct |
27 |
Correct |
18 ms |
23940 KB |
Output is correct |
28 |
Correct |
17 ms |
23912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Correct |
15 ms |
23936 KB |
Output is correct |
4 |
Correct |
13 ms |
23892 KB |
Output is correct |
5 |
Correct |
15 ms |
23892 KB |
Output is correct |
6 |
Correct |
13 ms |
23892 KB |
Output is correct |
7 |
Correct |
12 ms |
23868 KB |
Output is correct |
8 |
Correct |
14 ms |
23944 KB |
Output is correct |
9 |
Correct |
15 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23940 KB |
Output is correct |
11 |
Correct |
15 ms |
23892 KB |
Output is correct |
12 |
Correct |
14 ms |
23824 KB |
Output is correct |
13 |
Correct |
12 ms |
23940 KB |
Output is correct |
14 |
Correct |
13 ms |
23892 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
14 ms |
23892 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23856 KB |
Output is correct |
20 |
Correct |
15 ms |
23892 KB |
Output is correct |
21 |
Correct |
13 ms |
23892 KB |
Output is correct |
22 |
Correct |
14 ms |
23944 KB |
Output is correct |
23 |
Correct |
14 ms |
23940 KB |
Output is correct |
24 |
Correct |
13 ms |
23936 KB |
Output is correct |
25 |
Correct |
13 ms |
23832 KB |
Output is correct |
26 |
Correct |
15 ms |
23892 KB |
Output is correct |
27 |
Correct |
18 ms |
23940 KB |
Output is correct |
28 |
Correct |
17 ms |
23912 KB |
Output is correct |
29 |
Correct |
93 ms |
24008 KB |
Output is correct |
30 |
Correct |
155 ms |
24068 KB |
Output is correct |
31 |
Correct |
172 ms |
24148 KB |
Output is correct |
32 |
Correct |
128 ms |
24056 KB |
Output is correct |
33 |
Correct |
106 ms |
24076 KB |
Output is correct |
34 |
Correct |
166 ms |
24004 KB |
Output is correct |
35 |
Correct |
179 ms |
24020 KB |
Output is correct |
36 |
Correct |
63 ms |
24004 KB |
Output is correct |
37 |
Correct |
109 ms |
24084 KB |
Output is correct |
38 |
Correct |
117 ms |
24060 KB |
Output is correct |
39 |
Correct |
125 ms |
24080 KB |
Output is correct |
40 |
Correct |
120 ms |
24108 KB |
Output is correct |
41 |
Correct |
113 ms |
24092 KB |
Output is correct |
42 |
Correct |
118 ms |
24096 KB |
Output is correct |
43 |
Correct |
101 ms |
24060 KB |
Output is correct |
44 |
Correct |
128 ms |
24084 KB |
Output is correct |
45 |
Correct |
142 ms |
24080 KB |
Output is correct |
46 |
Correct |
150 ms |
24084 KB |
Output is correct |
47 |
Correct |
130 ms |
24072 KB |
Output is correct |
48 |
Correct |
127 ms |
24072 KB |
Output is correct |
49 |
Correct |
136 ms |
24068 KB |
Output is correct |
50 |
Correct |
185 ms |
24060 KB |
Output is correct |
51 |
Correct |
116 ms |
24080 KB |
Output is correct |
52 |
Correct |
123 ms |
24084 KB |
Output is correct |
53 |
Correct |
158 ms |
24084 KB |
Output is correct |
54 |
Correct |
183 ms |
24076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Execution timed out |
2077 ms |
34744 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Correct |
15 ms |
23936 KB |
Output is correct |
4 |
Correct |
13 ms |
23892 KB |
Output is correct |
5 |
Correct |
15 ms |
23892 KB |
Output is correct |
6 |
Correct |
13 ms |
23892 KB |
Output is correct |
7 |
Correct |
12 ms |
23868 KB |
Output is correct |
8 |
Correct |
14 ms |
23944 KB |
Output is correct |
9 |
Correct |
15 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23940 KB |
Output is correct |
11 |
Correct |
15 ms |
23892 KB |
Output is correct |
12 |
Correct |
14 ms |
23824 KB |
Output is correct |
13 |
Correct |
12 ms |
23940 KB |
Output is correct |
14 |
Correct |
13 ms |
23892 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
14 ms |
23892 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23856 KB |
Output is correct |
20 |
Correct |
15 ms |
23892 KB |
Output is correct |
21 |
Correct |
13 ms |
23892 KB |
Output is correct |
22 |
Correct |
14 ms |
23944 KB |
Output is correct |
23 |
Correct |
14 ms |
23940 KB |
Output is correct |
24 |
Correct |
13 ms |
23936 KB |
Output is correct |
25 |
Correct |
13 ms |
23832 KB |
Output is correct |
26 |
Correct |
15 ms |
23892 KB |
Output is correct |
27 |
Correct |
18 ms |
23940 KB |
Output is correct |
28 |
Correct |
17 ms |
23912 KB |
Output is correct |
29 |
Execution timed out |
2077 ms |
34744 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Correct |
15 ms |
23936 KB |
Output is correct |
4 |
Correct |
13 ms |
23892 KB |
Output is correct |
5 |
Correct |
15 ms |
23892 KB |
Output is correct |
6 |
Correct |
13 ms |
23892 KB |
Output is correct |
7 |
Correct |
12 ms |
23868 KB |
Output is correct |
8 |
Correct |
14 ms |
23944 KB |
Output is correct |
9 |
Correct |
15 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23940 KB |
Output is correct |
11 |
Correct |
15 ms |
23892 KB |
Output is correct |
12 |
Correct |
14 ms |
23824 KB |
Output is correct |
13 |
Correct |
12 ms |
23940 KB |
Output is correct |
14 |
Correct |
13 ms |
23892 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
14 ms |
23892 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23856 KB |
Output is correct |
20 |
Correct |
15 ms |
23892 KB |
Output is correct |
21 |
Correct |
13 ms |
23892 KB |
Output is correct |
22 |
Correct |
14 ms |
23944 KB |
Output is correct |
23 |
Correct |
14 ms |
23940 KB |
Output is correct |
24 |
Correct |
13 ms |
23936 KB |
Output is correct |
25 |
Correct |
13 ms |
23832 KB |
Output is correct |
26 |
Correct |
15 ms |
23892 KB |
Output is correct |
27 |
Correct |
18 ms |
23940 KB |
Output is correct |
28 |
Correct |
17 ms |
23912 KB |
Output is correct |
29 |
Correct |
93 ms |
24008 KB |
Output is correct |
30 |
Correct |
155 ms |
24068 KB |
Output is correct |
31 |
Correct |
172 ms |
24148 KB |
Output is correct |
32 |
Correct |
128 ms |
24056 KB |
Output is correct |
33 |
Correct |
106 ms |
24076 KB |
Output is correct |
34 |
Correct |
166 ms |
24004 KB |
Output is correct |
35 |
Correct |
179 ms |
24020 KB |
Output is correct |
36 |
Correct |
63 ms |
24004 KB |
Output is correct |
37 |
Correct |
109 ms |
24084 KB |
Output is correct |
38 |
Correct |
117 ms |
24060 KB |
Output is correct |
39 |
Correct |
125 ms |
24080 KB |
Output is correct |
40 |
Correct |
120 ms |
24108 KB |
Output is correct |
41 |
Correct |
113 ms |
24092 KB |
Output is correct |
42 |
Correct |
118 ms |
24096 KB |
Output is correct |
43 |
Correct |
101 ms |
24060 KB |
Output is correct |
44 |
Correct |
128 ms |
24084 KB |
Output is correct |
45 |
Correct |
142 ms |
24080 KB |
Output is correct |
46 |
Correct |
150 ms |
24084 KB |
Output is correct |
47 |
Correct |
130 ms |
24072 KB |
Output is correct |
48 |
Correct |
127 ms |
24072 KB |
Output is correct |
49 |
Correct |
136 ms |
24068 KB |
Output is correct |
50 |
Correct |
185 ms |
24060 KB |
Output is correct |
51 |
Correct |
116 ms |
24080 KB |
Output is correct |
52 |
Correct |
123 ms |
24084 KB |
Output is correct |
53 |
Correct |
158 ms |
24084 KB |
Output is correct |
54 |
Correct |
183 ms |
24076 KB |
Output is correct |
55 |
Execution timed out |
2089 ms |
39004 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
14 ms |
23892 KB |
Output is correct |
3 |
Correct |
15 ms |
23936 KB |
Output is correct |
4 |
Correct |
13 ms |
23892 KB |
Output is correct |
5 |
Correct |
15 ms |
23892 KB |
Output is correct |
6 |
Correct |
13 ms |
23892 KB |
Output is correct |
7 |
Correct |
12 ms |
23868 KB |
Output is correct |
8 |
Correct |
14 ms |
23944 KB |
Output is correct |
9 |
Correct |
15 ms |
23892 KB |
Output is correct |
10 |
Correct |
13 ms |
23940 KB |
Output is correct |
11 |
Correct |
15 ms |
23892 KB |
Output is correct |
12 |
Correct |
14 ms |
23824 KB |
Output is correct |
13 |
Correct |
12 ms |
23940 KB |
Output is correct |
14 |
Correct |
13 ms |
23892 KB |
Output is correct |
15 |
Correct |
13 ms |
23892 KB |
Output is correct |
16 |
Correct |
14 ms |
23892 KB |
Output is correct |
17 |
Correct |
13 ms |
23892 KB |
Output is correct |
18 |
Correct |
13 ms |
23916 KB |
Output is correct |
19 |
Correct |
13 ms |
23856 KB |
Output is correct |
20 |
Correct |
15 ms |
23892 KB |
Output is correct |
21 |
Correct |
13 ms |
23892 KB |
Output is correct |
22 |
Correct |
14 ms |
23944 KB |
Output is correct |
23 |
Correct |
14 ms |
23940 KB |
Output is correct |
24 |
Correct |
13 ms |
23936 KB |
Output is correct |
25 |
Correct |
13 ms |
23832 KB |
Output is correct |
26 |
Correct |
15 ms |
23892 KB |
Output is correct |
27 |
Correct |
18 ms |
23940 KB |
Output is correct |
28 |
Correct |
17 ms |
23912 KB |
Output is correct |
29 |
Correct |
93 ms |
24008 KB |
Output is correct |
30 |
Correct |
155 ms |
24068 KB |
Output is correct |
31 |
Correct |
172 ms |
24148 KB |
Output is correct |
32 |
Correct |
128 ms |
24056 KB |
Output is correct |
33 |
Correct |
106 ms |
24076 KB |
Output is correct |
34 |
Correct |
166 ms |
24004 KB |
Output is correct |
35 |
Correct |
179 ms |
24020 KB |
Output is correct |
36 |
Correct |
63 ms |
24004 KB |
Output is correct |
37 |
Correct |
109 ms |
24084 KB |
Output is correct |
38 |
Correct |
117 ms |
24060 KB |
Output is correct |
39 |
Correct |
125 ms |
24080 KB |
Output is correct |
40 |
Correct |
120 ms |
24108 KB |
Output is correct |
41 |
Correct |
113 ms |
24092 KB |
Output is correct |
42 |
Correct |
118 ms |
24096 KB |
Output is correct |
43 |
Correct |
101 ms |
24060 KB |
Output is correct |
44 |
Correct |
128 ms |
24084 KB |
Output is correct |
45 |
Correct |
142 ms |
24080 KB |
Output is correct |
46 |
Correct |
150 ms |
24084 KB |
Output is correct |
47 |
Correct |
130 ms |
24072 KB |
Output is correct |
48 |
Correct |
127 ms |
24072 KB |
Output is correct |
49 |
Correct |
136 ms |
24068 KB |
Output is correct |
50 |
Correct |
185 ms |
24060 KB |
Output is correct |
51 |
Correct |
116 ms |
24080 KB |
Output is correct |
52 |
Correct |
123 ms |
24084 KB |
Output is correct |
53 |
Correct |
158 ms |
24084 KB |
Output is correct |
54 |
Correct |
183 ms |
24076 KB |
Output is correct |
55 |
Execution timed out |
2077 ms |
34744 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |