#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m, q, flag;
vector<array<int, 2>> adj[(int)3e5], check((int)3e5);
vector<int> val((int)3e5, 1e18), vis((int)(3e5), -1);
void dfs(int p, int x, int y, int z, int par)
{
vis[p]=z%2;
if(y<x) swap(x, y);
for(auto i: adj[p])
{
if(i[1]>=x&&i[1]<=y) continue;
if(i[0]==par) continue;
if(vis[i[0]]==-1) dfs(i[0], x, y, z+1, p);
else if(vis[i[0]]!=-1&&(z+vis[i[0]]+1)%2==1) flag=1;
}
}
int bs(int pos)
{
int s=pos;
for(int i=20; i>=0; i--)
{
if(s+(1<<i)<=m)
{
int tmp=(s+(1<<i));
for(int i=1; i<=n; i++) vis[i]=-1;
flag=0;
for(int i=1; i<=n; i++) if(vis[i]==-1) dfs(i, pos, tmp, 0, i);
if(flag==1) s=tmp;
}
}
for(int i=1; i<=n; i++) vis[i]=-1;
flag=0;
for(int i=1; i<=n; i++) if(vis[i]==-1) dfs(i, pos, s, 0, i);
if(flag==0) s--;
return s;
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cin>>n>>m>>q;
for(int i=1; i<=m; i++)
{
int x, y; cin>>x>>y;
adj[x].push_back({y, i});
adj[y].push_back({x, i});
}
set<int> s;
if(n<=2000&&m<=2000&&q<=2000)
{
while(q--)
{
int l, r; cin>>l>>r;
if(val[l]==1e18)
val[l]=bs(l);
if(val[l]<r) cout<<"NO\n";
else cout<<"YES\n";
}
}
else
{
while(q--)
{
int l, r; cin>>l>>r;
if(val[l]==1e18)
val[l]=bs(l);
if(val[l]<r) cout<<"NO\n";
else cout<<"YES\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16696 KB |
Output is correct |
5 |
Correct |
7 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16724 KB |
Output is correct |
7 |
Correct |
10 ms |
16724 KB |
Output is correct |
8 |
Correct |
10 ms |
16752 KB |
Output is correct |
9 |
Correct |
10 ms |
16708 KB |
Output is correct |
10 |
Correct |
10 ms |
16724 KB |
Output is correct |
11 |
Correct |
11 ms |
16724 KB |
Output is correct |
12 |
Correct |
11 ms |
16724 KB |
Output is correct |
13 |
Correct |
8 ms |
16732 KB |
Output is correct |
14 |
Correct |
10 ms |
16736 KB |
Output is correct |
15 |
Correct |
10 ms |
16724 KB |
Output is correct |
16 |
Correct |
10 ms |
16724 KB |
Output is correct |
17 |
Correct |
9 ms |
16708 KB |
Output is correct |
18 |
Correct |
9 ms |
16724 KB |
Output is correct |
19 |
Correct |
9 ms |
16724 KB |
Output is correct |
20 |
Correct |
9 ms |
16724 KB |
Output is correct |
21 |
Correct |
10 ms |
16696 KB |
Output is correct |
22 |
Correct |
10 ms |
16668 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16724 KB |
Output is correct |
25 |
Correct |
10 ms |
16768 KB |
Output is correct |
26 |
Correct |
10 ms |
16724 KB |
Output is correct |
27 |
Correct |
10 ms |
16724 KB |
Output is correct |
28 |
Correct |
10 ms |
16724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16696 KB |
Output is correct |
5 |
Correct |
7 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16724 KB |
Output is correct |
7 |
Correct |
10 ms |
16724 KB |
Output is correct |
8 |
Correct |
10 ms |
16752 KB |
Output is correct |
9 |
Correct |
10 ms |
16708 KB |
Output is correct |
10 |
Correct |
10 ms |
16724 KB |
Output is correct |
11 |
Correct |
11 ms |
16724 KB |
Output is correct |
12 |
Correct |
11 ms |
16724 KB |
Output is correct |
13 |
Correct |
8 ms |
16732 KB |
Output is correct |
14 |
Correct |
10 ms |
16736 KB |
Output is correct |
15 |
Correct |
10 ms |
16724 KB |
Output is correct |
16 |
Correct |
10 ms |
16724 KB |
Output is correct |
17 |
Correct |
9 ms |
16708 KB |
Output is correct |
18 |
Correct |
9 ms |
16724 KB |
Output is correct |
19 |
Correct |
9 ms |
16724 KB |
Output is correct |
20 |
Correct |
9 ms |
16724 KB |
Output is correct |
21 |
Correct |
10 ms |
16696 KB |
Output is correct |
22 |
Correct |
10 ms |
16668 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16724 KB |
Output is correct |
25 |
Correct |
10 ms |
16768 KB |
Output is correct |
26 |
Correct |
10 ms |
16724 KB |
Output is correct |
27 |
Correct |
10 ms |
16724 KB |
Output is correct |
28 |
Correct |
10 ms |
16724 KB |
Output is correct |
29 |
Correct |
284 ms |
16816 KB |
Output is correct |
30 |
Correct |
503 ms |
16876 KB |
Output is correct |
31 |
Correct |
487 ms |
16916 KB |
Output is correct |
32 |
Correct |
359 ms |
16912 KB |
Output is correct |
33 |
Correct |
283 ms |
16852 KB |
Output is correct |
34 |
Correct |
494 ms |
16904 KB |
Output is correct |
35 |
Correct |
611 ms |
16900 KB |
Output is correct |
36 |
Correct |
163 ms |
16924 KB |
Output is correct |
37 |
Correct |
402 ms |
17028 KB |
Output is correct |
38 |
Correct |
519 ms |
16872 KB |
Output is correct |
39 |
Correct |
411 ms |
17016 KB |
Output is correct |
40 |
Correct |
330 ms |
16852 KB |
Output is correct |
41 |
Correct |
333 ms |
16852 KB |
Output is correct |
42 |
Correct |
328 ms |
16924 KB |
Output is correct |
43 |
Correct |
295 ms |
16904 KB |
Output is correct |
44 |
Correct |
377 ms |
16852 KB |
Output is correct |
45 |
Correct |
457 ms |
16852 KB |
Output is correct |
46 |
Correct |
586 ms |
16900 KB |
Output is correct |
47 |
Correct |
345 ms |
16912 KB |
Output is correct |
48 |
Correct |
365 ms |
16896 KB |
Output is correct |
49 |
Correct |
449 ms |
17024 KB |
Output is correct |
50 |
Correct |
528 ms |
16884 KB |
Output is correct |
51 |
Correct |
325 ms |
16980 KB |
Output is correct |
52 |
Correct |
379 ms |
16912 KB |
Output is correct |
53 |
Correct |
447 ms |
16904 KB |
Output is correct |
54 |
Correct |
590 ms |
17024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
225 ms |
30764 KB |
Output is correct |
4 |
Correct |
387 ms |
31012 KB |
Output is correct |
5 |
Correct |
274 ms |
29464 KB |
Output is correct |
6 |
Correct |
304 ms |
31840 KB |
Output is correct |
7 |
Correct |
334 ms |
31648 KB |
Output is correct |
8 |
Correct |
287 ms |
31872 KB |
Output is correct |
9 |
Correct |
411 ms |
32392 KB |
Output is correct |
10 |
Correct |
485 ms |
30180 KB |
Output is correct |
11 |
Correct |
355 ms |
30728 KB |
Output is correct |
12 |
Correct |
386 ms |
29224 KB |
Output is correct |
13 |
Correct |
193 ms |
30224 KB |
Output is correct |
14 |
Correct |
317 ms |
31700 KB |
Output is correct |
15 |
Correct |
423 ms |
31568 KB |
Output is correct |
16 |
Correct |
476 ms |
30012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16696 KB |
Output is correct |
5 |
Correct |
7 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16724 KB |
Output is correct |
7 |
Correct |
10 ms |
16724 KB |
Output is correct |
8 |
Correct |
10 ms |
16752 KB |
Output is correct |
9 |
Correct |
10 ms |
16708 KB |
Output is correct |
10 |
Correct |
10 ms |
16724 KB |
Output is correct |
11 |
Correct |
11 ms |
16724 KB |
Output is correct |
12 |
Correct |
11 ms |
16724 KB |
Output is correct |
13 |
Correct |
8 ms |
16732 KB |
Output is correct |
14 |
Correct |
10 ms |
16736 KB |
Output is correct |
15 |
Correct |
10 ms |
16724 KB |
Output is correct |
16 |
Correct |
10 ms |
16724 KB |
Output is correct |
17 |
Correct |
9 ms |
16708 KB |
Output is correct |
18 |
Correct |
9 ms |
16724 KB |
Output is correct |
19 |
Correct |
9 ms |
16724 KB |
Output is correct |
20 |
Correct |
9 ms |
16724 KB |
Output is correct |
21 |
Correct |
10 ms |
16696 KB |
Output is correct |
22 |
Correct |
10 ms |
16668 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16724 KB |
Output is correct |
25 |
Correct |
10 ms |
16768 KB |
Output is correct |
26 |
Correct |
10 ms |
16724 KB |
Output is correct |
27 |
Correct |
10 ms |
16724 KB |
Output is correct |
28 |
Correct |
10 ms |
16724 KB |
Output is correct |
29 |
Correct |
225 ms |
30764 KB |
Output is correct |
30 |
Correct |
387 ms |
31012 KB |
Output is correct |
31 |
Correct |
274 ms |
29464 KB |
Output is correct |
32 |
Correct |
304 ms |
31840 KB |
Output is correct |
33 |
Correct |
334 ms |
31648 KB |
Output is correct |
34 |
Correct |
287 ms |
31872 KB |
Output is correct |
35 |
Correct |
411 ms |
32392 KB |
Output is correct |
36 |
Correct |
485 ms |
30180 KB |
Output is correct |
37 |
Correct |
355 ms |
30728 KB |
Output is correct |
38 |
Correct |
386 ms |
29224 KB |
Output is correct |
39 |
Correct |
193 ms |
30224 KB |
Output is correct |
40 |
Correct |
317 ms |
31700 KB |
Output is correct |
41 |
Correct |
423 ms |
31568 KB |
Output is correct |
42 |
Correct |
476 ms |
30012 KB |
Output is correct |
43 |
Execution timed out |
2041 ms |
32988 KB |
Time limit exceeded |
44 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16696 KB |
Output is correct |
5 |
Correct |
7 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16724 KB |
Output is correct |
7 |
Correct |
10 ms |
16724 KB |
Output is correct |
8 |
Correct |
10 ms |
16752 KB |
Output is correct |
9 |
Correct |
10 ms |
16708 KB |
Output is correct |
10 |
Correct |
10 ms |
16724 KB |
Output is correct |
11 |
Correct |
11 ms |
16724 KB |
Output is correct |
12 |
Correct |
11 ms |
16724 KB |
Output is correct |
13 |
Correct |
8 ms |
16732 KB |
Output is correct |
14 |
Correct |
10 ms |
16736 KB |
Output is correct |
15 |
Correct |
10 ms |
16724 KB |
Output is correct |
16 |
Correct |
10 ms |
16724 KB |
Output is correct |
17 |
Correct |
9 ms |
16708 KB |
Output is correct |
18 |
Correct |
9 ms |
16724 KB |
Output is correct |
19 |
Correct |
9 ms |
16724 KB |
Output is correct |
20 |
Correct |
9 ms |
16724 KB |
Output is correct |
21 |
Correct |
10 ms |
16696 KB |
Output is correct |
22 |
Correct |
10 ms |
16668 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16724 KB |
Output is correct |
25 |
Correct |
10 ms |
16768 KB |
Output is correct |
26 |
Correct |
10 ms |
16724 KB |
Output is correct |
27 |
Correct |
10 ms |
16724 KB |
Output is correct |
28 |
Correct |
10 ms |
16724 KB |
Output is correct |
29 |
Correct |
284 ms |
16816 KB |
Output is correct |
30 |
Correct |
503 ms |
16876 KB |
Output is correct |
31 |
Correct |
487 ms |
16916 KB |
Output is correct |
32 |
Correct |
359 ms |
16912 KB |
Output is correct |
33 |
Correct |
283 ms |
16852 KB |
Output is correct |
34 |
Correct |
494 ms |
16904 KB |
Output is correct |
35 |
Correct |
611 ms |
16900 KB |
Output is correct |
36 |
Correct |
163 ms |
16924 KB |
Output is correct |
37 |
Correct |
402 ms |
17028 KB |
Output is correct |
38 |
Correct |
519 ms |
16872 KB |
Output is correct |
39 |
Correct |
411 ms |
17016 KB |
Output is correct |
40 |
Correct |
330 ms |
16852 KB |
Output is correct |
41 |
Correct |
333 ms |
16852 KB |
Output is correct |
42 |
Correct |
328 ms |
16924 KB |
Output is correct |
43 |
Correct |
295 ms |
16904 KB |
Output is correct |
44 |
Correct |
377 ms |
16852 KB |
Output is correct |
45 |
Correct |
457 ms |
16852 KB |
Output is correct |
46 |
Correct |
586 ms |
16900 KB |
Output is correct |
47 |
Correct |
345 ms |
16912 KB |
Output is correct |
48 |
Correct |
365 ms |
16896 KB |
Output is correct |
49 |
Correct |
449 ms |
17024 KB |
Output is correct |
50 |
Correct |
528 ms |
16884 KB |
Output is correct |
51 |
Correct |
325 ms |
16980 KB |
Output is correct |
52 |
Correct |
379 ms |
16912 KB |
Output is correct |
53 |
Correct |
447 ms |
16904 KB |
Output is correct |
54 |
Correct |
590 ms |
17024 KB |
Output is correct |
55 |
Execution timed out |
2080 ms |
31820 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
8 ms |
16724 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16696 KB |
Output is correct |
5 |
Correct |
7 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16724 KB |
Output is correct |
7 |
Correct |
10 ms |
16724 KB |
Output is correct |
8 |
Correct |
10 ms |
16752 KB |
Output is correct |
9 |
Correct |
10 ms |
16708 KB |
Output is correct |
10 |
Correct |
10 ms |
16724 KB |
Output is correct |
11 |
Correct |
11 ms |
16724 KB |
Output is correct |
12 |
Correct |
11 ms |
16724 KB |
Output is correct |
13 |
Correct |
8 ms |
16732 KB |
Output is correct |
14 |
Correct |
10 ms |
16736 KB |
Output is correct |
15 |
Correct |
10 ms |
16724 KB |
Output is correct |
16 |
Correct |
10 ms |
16724 KB |
Output is correct |
17 |
Correct |
9 ms |
16708 KB |
Output is correct |
18 |
Correct |
9 ms |
16724 KB |
Output is correct |
19 |
Correct |
9 ms |
16724 KB |
Output is correct |
20 |
Correct |
9 ms |
16724 KB |
Output is correct |
21 |
Correct |
10 ms |
16696 KB |
Output is correct |
22 |
Correct |
10 ms |
16668 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16724 KB |
Output is correct |
25 |
Correct |
10 ms |
16768 KB |
Output is correct |
26 |
Correct |
10 ms |
16724 KB |
Output is correct |
27 |
Correct |
10 ms |
16724 KB |
Output is correct |
28 |
Correct |
10 ms |
16724 KB |
Output is correct |
29 |
Correct |
284 ms |
16816 KB |
Output is correct |
30 |
Correct |
503 ms |
16876 KB |
Output is correct |
31 |
Correct |
487 ms |
16916 KB |
Output is correct |
32 |
Correct |
359 ms |
16912 KB |
Output is correct |
33 |
Correct |
283 ms |
16852 KB |
Output is correct |
34 |
Correct |
494 ms |
16904 KB |
Output is correct |
35 |
Correct |
611 ms |
16900 KB |
Output is correct |
36 |
Correct |
163 ms |
16924 KB |
Output is correct |
37 |
Correct |
402 ms |
17028 KB |
Output is correct |
38 |
Correct |
519 ms |
16872 KB |
Output is correct |
39 |
Correct |
411 ms |
17016 KB |
Output is correct |
40 |
Correct |
330 ms |
16852 KB |
Output is correct |
41 |
Correct |
333 ms |
16852 KB |
Output is correct |
42 |
Correct |
328 ms |
16924 KB |
Output is correct |
43 |
Correct |
295 ms |
16904 KB |
Output is correct |
44 |
Correct |
377 ms |
16852 KB |
Output is correct |
45 |
Correct |
457 ms |
16852 KB |
Output is correct |
46 |
Correct |
586 ms |
16900 KB |
Output is correct |
47 |
Correct |
345 ms |
16912 KB |
Output is correct |
48 |
Correct |
365 ms |
16896 KB |
Output is correct |
49 |
Correct |
449 ms |
17024 KB |
Output is correct |
50 |
Correct |
528 ms |
16884 KB |
Output is correct |
51 |
Correct |
325 ms |
16980 KB |
Output is correct |
52 |
Correct |
379 ms |
16912 KB |
Output is correct |
53 |
Correct |
447 ms |
16904 KB |
Output is correct |
54 |
Correct |
590 ms |
17024 KB |
Output is correct |
55 |
Correct |
225 ms |
30764 KB |
Output is correct |
56 |
Correct |
387 ms |
31012 KB |
Output is correct |
57 |
Correct |
274 ms |
29464 KB |
Output is correct |
58 |
Correct |
304 ms |
31840 KB |
Output is correct |
59 |
Correct |
334 ms |
31648 KB |
Output is correct |
60 |
Correct |
287 ms |
31872 KB |
Output is correct |
61 |
Correct |
411 ms |
32392 KB |
Output is correct |
62 |
Correct |
485 ms |
30180 KB |
Output is correct |
63 |
Correct |
355 ms |
30728 KB |
Output is correct |
64 |
Correct |
386 ms |
29224 KB |
Output is correct |
65 |
Correct |
193 ms |
30224 KB |
Output is correct |
66 |
Correct |
317 ms |
31700 KB |
Output is correct |
67 |
Correct |
423 ms |
31568 KB |
Output is correct |
68 |
Correct |
476 ms |
30012 KB |
Output is correct |
69 |
Execution timed out |
2041 ms |
32988 KB |
Time limit exceeded |
70 |
Halted |
0 ms |
0 KB |
- |