//#ifdef ONLINE_JUDGE
// #include "cyberland.h"
//#endif
#include <bits/stdc++.h>
#define se second
#define fs first
#define mp make_pair
#define pb push_back
#define ll long long
#define ii pair<ll,ll>
#define ld long double
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define bit(msk, i) ((msk >> i) & 1)
#define iter(id, v) for(auto id : v)
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
using namespace std;
mt19937_64 rd(chrono :: steady_clock :: now().time_since_epoch().count());
ll Rand(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rd); }
const int N = 2e5 + 2;
const ll Mod = 998244353;
const int szBL = 50;
const int INF = 1e9 + 7;
const int BASE = 137;
struct Query {
int L, R;
};
int n, m, Q;
pair<int,int> edges[N];
Query qr[N];
namespace sub3 {
vector<pair<int,int>> ke[N];
int num[N], high[N];
int time_dfs = 0, res = 0;
void dfs (int u, int p, int L, int R) {
num[u] = 1;
high[u] = high[p] + 1;
iter (&id, ke[u]) {
int v, idx;
tie (v, idx) = id;
if (v == p || (idx >= L && idx <= R)) continue;
if (!num[v]) {
dfs (v, u, L, R);
}
else res = max(res, (high[u] - high[v] + 1) % 2);
}
}
void solution() {
rep (i, 1, m) {
int u, v;
tie(u, v) = edges[i];
ke[u].push_back({v, i});
ke[v].push_back({u, i});
}
rep (q, 1, Q) {
int L = qr[q].L, R = qr[q].R;
rep (u, 1, n) num[u] = 0;
res = 0;
rep (u, 1, n) {
if (num[u]) continue;
time_dfs = 0;
dfs (u, 0, L, R);
}
if (res) cout << "YES\n";
else cout <<"NO\n";
}
}
}
void solution() {
cin >> n >> m >> Q;
rep (i, 1, m) {
cin >> edges[i].fs >> edges[i].se;
}
rep (i, 1, Q) {
cin >> qr[i].L >> qr[i].R;
}
if (Q <= 2000) sub3 :: solution();
else cout << -1 <<"\n";
}
#define file(name) freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);
int main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// file ("PAINT");
int num_Test = 1;
// cin >> num_Test;
while (num_Test--)
solution();
}
/*
5 7
11011
query 1 2
query 1 2
query 1 2
query 3 4
toggle 3
query 3 4
query 1 2
3 2
0 1 5
0 2 5
1
1 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
2 ms |
8680 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
2 ms |
8540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
2 ms |
8680 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
2 ms |
8540 KB |
Output is correct |
29 |
Correct |
34 ms |
8540 KB |
Output is correct |
30 |
Correct |
85 ms |
8536 KB |
Output is correct |
31 |
Correct |
76 ms |
8540 KB |
Output is correct |
32 |
Correct |
60 ms |
8540 KB |
Output is correct |
33 |
Correct |
46 ms |
8784 KB |
Output is correct |
34 |
Correct |
78 ms |
8772 KB |
Output is correct |
35 |
Correct |
85 ms |
8788 KB |
Output is correct |
36 |
Correct |
30 ms |
8796 KB |
Output is correct |
37 |
Correct |
42 ms |
8792 KB |
Output is correct |
38 |
Correct |
38 ms |
8540 KB |
Output is correct |
39 |
Correct |
49 ms |
8540 KB |
Output is correct |
40 |
Correct |
51 ms |
8796 KB |
Output is correct |
41 |
Correct |
56 ms |
8796 KB |
Output is correct |
42 |
Correct |
52 ms |
8792 KB |
Output is correct |
43 |
Correct |
44 ms |
8536 KB |
Output is correct |
44 |
Correct |
58 ms |
8540 KB |
Output is correct |
45 |
Correct |
67 ms |
8536 KB |
Output is correct |
46 |
Correct |
72 ms |
8540 KB |
Output is correct |
47 |
Correct |
47 ms |
8540 KB |
Output is correct |
48 |
Correct |
49 ms |
8536 KB |
Output is correct |
49 |
Correct |
62 ms |
8536 KB |
Output is correct |
50 |
Correct |
71 ms |
8540 KB |
Output is correct |
51 |
Correct |
50 ms |
8780 KB |
Output is correct |
52 |
Correct |
65 ms |
8792 KB |
Output is correct |
53 |
Correct |
71 ms |
8772 KB |
Output is correct |
54 |
Correct |
85 ms |
8792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Incorrect |
36 ms |
9600 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
2 ms |
8680 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
2 ms |
8540 KB |
Output is correct |
29 |
Incorrect |
36 ms |
9600 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
2 ms |
8680 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
2 ms |
8540 KB |
Output is correct |
29 |
Correct |
34 ms |
8540 KB |
Output is correct |
30 |
Correct |
85 ms |
8536 KB |
Output is correct |
31 |
Correct |
76 ms |
8540 KB |
Output is correct |
32 |
Correct |
60 ms |
8540 KB |
Output is correct |
33 |
Correct |
46 ms |
8784 KB |
Output is correct |
34 |
Correct |
78 ms |
8772 KB |
Output is correct |
35 |
Correct |
85 ms |
8788 KB |
Output is correct |
36 |
Correct |
30 ms |
8796 KB |
Output is correct |
37 |
Correct |
42 ms |
8792 KB |
Output is correct |
38 |
Correct |
38 ms |
8540 KB |
Output is correct |
39 |
Correct |
49 ms |
8540 KB |
Output is correct |
40 |
Correct |
51 ms |
8796 KB |
Output is correct |
41 |
Correct |
56 ms |
8796 KB |
Output is correct |
42 |
Correct |
52 ms |
8792 KB |
Output is correct |
43 |
Correct |
44 ms |
8536 KB |
Output is correct |
44 |
Correct |
58 ms |
8540 KB |
Output is correct |
45 |
Correct |
67 ms |
8536 KB |
Output is correct |
46 |
Correct |
72 ms |
8540 KB |
Output is correct |
47 |
Correct |
47 ms |
8540 KB |
Output is correct |
48 |
Correct |
49 ms |
8536 KB |
Output is correct |
49 |
Correct |
62 ms |
8536 KB |
Output is correct |
50 |
Correct |
71 ms |
8540 KB |
Output is correct |
51 |
Correct |
50 ms |
8780 KB |
Output is correct |
52 |
Correct |
65 ms |
8792 KB |
Output is correct |
53 |
Correct |
71 ms |
8772 KB |
Output is correct |
54 |
Correct |
85 ms |
8792 KB |
Output is correct |
55 |
Execution timed out |
2061 ms |
21784 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
2 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
2 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
2 ms |
8540 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
2 ms |
8536 KB |
Output is correct |
15 |
Correct |
2 ms |
8540 KB |
Output is correct |
16 |
Correct |
2 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
2 ms |
8680 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
2 ms |
8540 KB |
Output is correct |
29 |
Correct |
34 ms |
8540 KB |
Output is correct |
30 |
Correct |
85 ms |
8536 KB |
Output is correct |
31 |
Correct |
76 ms |
8540 KB |
Output is correct |
32 |
Correct |
60 ms |
8540 KB |
Output is correct |
33 |
Correct |
46 ms |
8784 KB |
Output is correct |
34 |
Correct |
78 ms |
8772 KB |
Output is correct |
35 |
Correct |
85 ms |
8788 KB |
Output is correct |
36 |
Correct |
30 ms |
8796 KB |
Output is correct |
37 |
Correct |
42 ms |
8792 KB |
Output is correct |
38 |
Correct |
38 ms |
8540 KB |
Output is correct |
39 |
Correct |
49 ms |
8540 KB |
Output is correct |
40 |
Correct |
51 ms |
8796 KB |
Output is correct |
41 |
Correct |
56 ms |
8796 KB |
Output is correct |
42 |
Correct |
52 ms |
8792 KB |
Output is correct |
43 |
Correct |
44 ms |
8536 KB |
Output is correct |
44 |
Correct |
58 ms |
8540 KB |
Output is correct |
45 |
Correct |
67 ms |
8536 KB |
Output is correct |
46 |
Correct |
72 ms |
8540 KB |
Output is correct |
47 |
Correct |
47 ms |
8540 KB |
Output is correct |
48 |
Correct |
49 ms |
8536 KB |
Output is correct |
49 |
Correct |
62 ms |
8536 KB |
Output is correct |
50 |
Correct |
71 ms |
8540 KB |
Output is correct |
51 |
Correct |
50 ms |
8780 KB |
Output is correct |
52 |
Correct |
65 ms |
8792 KB |
Output is correct |
53 |
Correct |
71 ms |
8772 KB |
Output is correct |
54 |
Correct |
85 ms |
8792 KB |
Output is correct |
55 |
Incorrect |
36 ms |
9600 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |