# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
642413 |
2022-09-19T11:38:50 Z |
berr |
Joker (BOI20_joker) |
C++17 |
|
2000 ms |
34788 KB |
#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});
}
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
{
for(int i=1; i<=200; i++)
{
val[i]=bs(i);
}
while(q--)
{
int l, r; cin>>l>>r;
if(r>val[l]) cout<<"NO\n";
else cout<<"YES\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16724 KB |
Output is correct |
5 |
Correct |
8 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16652 KB |
Output is correct |
7 |
Correct |
10 ms |
16900 KB |
Output is correct |
8 |
Correct |
11 ms |
16772 KB |
Output is correct |
9 |
Correct |
11 ms |
16772 KB |
Output is correct |
10 |
Correct |
11 ms |
16724 KB |
Output is correct |
11 |
Correct |
12 ms |
16724 KB |
Output is correct |
12 |
Correct |
12 ms |
16756 KB |
Output is correct |
13 |
Correct |
10 ms |
16724 KB |
Output is correct |
14 |
Correct |
11 ms |
16768 KB |
Output is correct |
15 |
Correct |
13 ms |
16776 KB |
Output is correct |
16 |
Correct |
11 ms |
16772 KB |
Output is correct |
17 |
Correct |
11 ms |
16724 KB |
Output is correct |
18 |
Correct |
11 ms |
16704 KB |
Output is correct |
19 |
Correct |
10 ms |
16724 KB |
Output is correct |
20 |
Correct |
11 ms |
16780 KB |
Output is correct |
21 |
Correct |
11 ms |
16772 KB |
Output is correct |
22 |
Correct |
11 ms |
16776 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16692 KB |
Output is correct |
25 |
Correct |
11 ms |
16772 KB |
Output is correct |
26 |
Correct |
11 ms |
16772 KB |
Output is correct |
27 |
Correct |
11 ms |
16696 KB |
Output is correct |
28 |
Correct |
12 ms |
16772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16724 KB |
Output is correct |
5 |
Correct |
8 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16652 KB |
Output is correct |
7 |
Correct |
10 ms |
16900 KB |
Output is correct |
8 |
Correct |
11 ms |
16772 KB |
Output is correct |
9 |
Correct |
11 ms |
16772 KB |
Output is correct |
10 |
Correct |
11 ms |
16724 KB |
Output is correct |
11 |
Correct |
12 ms |
16724 KB |
Output is correct |
12 |
Correct |
12 ms |
16756 KB |
Output is correct |
13 |
Correct |
10 ms |
16724 KB |
Output is correct |
14 |
Correct |
11 ms |
16768 KB |
Output is correct |
15 |
Correct |
13 ms |
16776 KB |
Output is correct |
16 |
Correct |
11 ms |
16772 KB |
Output is correct |
17 |
Correct |
11 ms |
16724 KB |
Output is correct |
18 |
Correct |
11 ms |
16704 KB |
Output is correct |
19 |
Correct |
10 ms |
16724 KB |
Output is correct |
20 |
Correct |
11 ms |
16780 KB |
Output is correct |
21 |
Correct |
11 ms |
16772 KB |
Output is correct |
22 |
Correct |
11 ms |
16776 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16692 KB |
Output is correct |
25 |
Correct |
11 ms |
16772 KB |
Output is correct |
26 |
Correct |
11 ms |
16772 KB |
Output is correct |
27 |
Correct |
11 ms |
16696 KB |
Output is correct |
28 |
Correct |
12 ms |
16772 KB |
Output is correct |
29 |
Correct |
281 ms |
16820 KB |
Output is correct |
30 |
Correct |
513 ms |
17028 KB |
Output is correct |
31 |
Correct |
475 ms |
16852 KB |
Output is correct |
32 |
Correct |
348 ms |
16944 KB |
Output is correct |
33 |
Correct |
265 ms |
16932 KB |
Output is correct |
34 |
Correct |
495 ms |
16972 KB |
Output is correct |
35 |
Correct |
609 ms |
16940 KB |
Output is correct |
36 |
Correct |
148 ms |
16852 KB |
Output is correct |
37 |
Correct |
383 ms |
16936 KB |
Output is correct |
38 |
Correct |
497 ms |
16912 KB |
Output is correct |
39 |
Correct |
398 ms |
16936 KB |
Output is correct |
40 |
Correct |
315 ms |
16852 KB |
Output is correct |
41 |
Correct |
318 ms |
16852 KB |
Output is correct |
42 |
Correct |
333 ms |
17108 KB |
Output is correct |
43 |
Correct |
282 ms |
16932 KB |
Output is correct |
44 |
Correct |
377 ms |
16952 KB |
Output is correct |
45 |
Correct |
445 ms |
16860 KB |
Output is correct |
46 |
Correct |
577 ms |
16976 KB |
Output is correct |
47 |
Correct |
322 ms |
16928 KB |
Output is correct |
48 |
Correct |
353 ms |
17068 KB |
Output is correct |
49 |
Correct |
425 ms |
16852 KB |
Output is correct |
50 |
Correct |
524 ms |
16932 KB |
Output is correct |
51 |
Correct |
318 ms |
16944 KB |
Output is correct |
52 |
Correct |
372 ms |
16852 KB |
Output is correct |
53 |
Correct |
438 ms |
17032 KB |
Output is correct |
54 |
Correct |
570 ms |
16852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Execution timed out |
2066 ms |
32380 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16724 KB |
Output is correct |
5 |
Correct |
8 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16652 KB |
Output is correct |
7 |
Correct |
10 ms |
16900 KB |
Output is correct |
8 |
Correct |
11 ms |
16772 KB |
Output is correct |
9 |
Correct |
11 ms |
16772 KB |
Output is correct |
10 |
Correct |
11 ms |
16724 KB |
Output is correct |
11 |
Correct |
12 ms |
16724 KB |
Output is correct |
12 |
Correct |
12 ms |
16756 KB |
Output is correct |
13 |
Correct |
10 ms |
16724 KB |
Output is correct |
14 |
Correct |
11 ms |
16768 KB |
Output is correct |
15 |
Correct |
13 ms |
16776 KB |
Output is correct |
16 |
Correct |
11 ms |
16772 KB |
Output is correct |
17 |
Correct |
11 ms |
16724 KB |
Output is correct |
18 |
Correct |
11 ms |
16704 KB |
Output is correct |
19 |
Correct |
10 ms |
16724 KB |
Output is correct |
20 |
Correct |
11 ms |
16780 KB |
Output is correct |
21 |
Correct |
11 ms |
16772 KB |
Output is correct |
22 |
Correct |
11 ms |
16776 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16692 KB |
Output is correct |
25 |
Correct |
11 ms |
16772 KB |
Output is correct |
26 |
Correct |
11 ms |
16772 KB |
Output is correct |
27 |
Correct |
11 ms |
16696 KB |
Output is correct |
28 |
Correct |
12 ms |
16772 KB |
Output is correct |
29 |
Execution timed out |
2066 ms |
32380 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16724 KB |
Output is correct |
5 |
Correct |
8 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16652 KB |
Output is correct |
7 |
Correct |
10 ms |
16900 KB |
Output is correct |
8 |
Correct |
11 ms |
16772 KB |
Output is correct |
9 |
Correct |
11 ms |
16772 KB |
Output is correct |
10 |
Correct |
11 ms |
16724 KB |
Output is correct |
11 |
Correct |
12 ms |
16724 KB |
Output is correct |
12 |
Correct |
12 ms |
16756 KB |
Output is correct |
13 |
Correct |
10 ms |
16724 KB |
Output is correct |
14 |
Correct |
11 ms |
16768 KB |
Output is correct |
15 |
Correct |
13 ms |
16776 KB |
Output is correct |
16 |
Correct |
11 ms |
16772 KB |
Output is correct |
17 |
Correct |
11 ms |
16724 KB |
Output is correct |
18 |
Correct |
11 ms |
16704 KB |
Output is correct |
19 |
Correct |
10 ms |
16724 KB |
Output is correct |
20 |
Correct |
11 ms |
16780 KB |
Output is correct |
21 |
Correct |
11 ms |
16772 KB |
Output is correct |
22 |
Correct |
11 ms |
16776 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16692 KB |
Output is correct |
25 |
Correct |
11 ms |
16772 KB |
Output is correct |
26 |
Correct |
11 ms |
16772 KB |
Output is correct |
27 |
Correct |
11 ms |
16696 KB |
Output is correct |
28 |
Correct |
12 ms |
16772 KB |
Output is correct |
29 |
Correct |
281 ms |
16820 KB |
Output is correct |
30 |
Correct |
513 ms |
17028 KB |
Output is correct |
31 |
Correct |
475 ms |
16852 KB |
Output is correct |
32 |
Correct |
348 ms |
16944 KB |
Output is correct |
33 |
Correct |
265 ms |
16932 KB |
Output is correct |
34 |
Correct |
495 ms |
16972 KB |
Output is correct |
35 |
Correct |
609 ms |
16940 KB |
Output is correct |
36 |
Correct |
148 ms |
16852 KB |
Output is correct |
37 |
Correct |
383 ms |
16936 KB |
Output is correct |
38 |
Correct |
497 ms |
16912 KB |
Output is correct |
39 |
Correct |
398 ms |
16936 KB |
Output is correct |
40 |
Correct |
315 ms |
16852 KB |
Output is correct |
41 |
Correct |
318 ms |
16852 KB |
Output is correct |
42 |
Correct |
333 ms |
17108 KB |
Output is correct |
43 |
Correct |
282 ms |
16932 KB |
Output is correct |
44 |
Correct |
377 ms |
16952 KB |
Output is correct |
45 |
Correct |
445 ms |
16860 KB |
Output is correct |
46 |
Correct |
577 ms |
16976 KB |
Output is correct |
47 |
Correct |
322 ms |
16928 KB |
Output is correct |
48 |
Correct |
353 ms |
17068 KB |
Output is correct |
49 |
Correct |
425 ms |
16852 KB |
Output is correct |
50 |
Correct |
524 ms |
16932 KB |
Output is correct |
51 |
Correct |
318 ms |
16944 KB |
Output is correct |
52 |
Correct |
372 ms |
16852 KB |
Output is correct |
53 |
Correct |
438 ms |
17032 KB |
Output is correct |
54 |
Correct |
570 ms |
16852 KB |
Output is correct |
55 |
Execution timed out |
2082 ms |
34788 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16724 KB |
Output is correct |
2 |
Correct |
10 ms |
16684 KB |
Output is correct |
3 |
Correct |
9 ms |
16724 KB |
Output is correct |
4 |
Correct |
9 ms |
16724 KB |
Output is correct |
5 |
Correct |
8 ms |
16724 KB |
Output is correct |
6 |
Correct |
8 ms |
16652 KB |
Output is correct |
7 |
Correct |
10 ms |
16900 KB |
Output is correct |
8 |
Correct |
11 ms |
16772 KB |
Output is correct |
9 |
Correct |
11 ms |
16772 KB |
Output is correct |
10 |
Correct |
11 ms |
16724 KB |
Output is correct |
11 |
Correct |
12 ms |
16724 KB |
Output is correct |
12 |
Correct |
12 ms |
16756 KB |
Output is correct |
13 |
Correct |
10 ms |
16724 KB |
Output is correct |
14 |
Correct |
11 ms |
16768 KB |
Output is correct |
15 |
Correct |
13 ms |
16776 KB |
Output is correct |
16 |
Correct |
11 ms |
16772 KB |
Output is correct |
17 |
Correct |
11 ms |
16724 KB |
Output is correct |
18 |
Correct |
11 ms |
16704 KB |
Output is correct |
19 |
Correct |
10 ms |
16724 KB |
Output is correct |
20 |
Correct |
11 ms |
16780 KB |
Output is correct |
21 |
Correct |
11 ms |
16772 KB |
Output is correct |
22 |
Correct |
11 ms |
16776 KB |
Output is correct |
23 |
Correct |
10 ms |
16724 KB |
Output is correct |
24 |
Correct |
11 ms |
16692 KB |
Output is correct |
25 |
Correct |
11 ms |
16772 KB |
Output is correct |
26 |
Correct |
11 ms |
16772 KB |
Output is correct |
27 |
Correct |
11 ms |
16696 KB |
Output is correct |
28 |
Correct |
12 ms |
16772 KB |
Output is correct |
29 |
Correct |
281 ms |
16820 KB |
Output is correct |
30 |
Correct |
513 ms |
17028 KB |
Output is correct |
31 |
Correct |
475 ms |
16852 KB |
Output is correct |
32 |
Correct |
348 ms |
16944 KB |
Output is correct |
33 |
Correct |
265 ms |
16932 KB |
Output is correct |
34 |
Correct |
495 ms |
16972 KB |
Output is correct |
35 |
Correct |
609 ms |
16940 KB |
Output is correct |
36 |
Correct |
148 ms |
16852 KB |
Output is correct |
37 |
Correct |
383 ms |
16936 KB |
Output is correct |
38 |
Correct |
497 ms |
16912 KB |
Output is correct |
39 |
Correct |
398 ms |
16936 KB |
Output is correct |
40 |
Correct |
315 ms |
16852 KB |
Output is correct |
41 |
Correct |
318 ms |
16852 KB |
Output is correct |
42 |
Correct |
333 ms |
17108 KB |
Output is correct |
43 |
Correct |
282 ms |
16932 KB |
Output is correct |
44 |
Correct |
377 ms |
16952 KB |
Output is correct |
45 |
Correct |
445 ms |
16860 KB |
Output is correct |
46 |
Correct |
577 ms |
16976 KB |
Output is correct |
47 |
Correct |
322 ms |
16928 KB |
Output is correct |
48 |
Correct |
353 ms |
17068 KB |
Output is correct |
49 |
Correct |
425 ms |
16852 KB |
Output is correct |
50 |
Correct |
524 ms |
16932 KB |
Output is correct |
51 |
Correct |
318 ms |
16944 KB |
Output is correct |
52 |
Correct |
372 ms |
16852 KB |
Output is correct |
53 |
Correct |
438 ms |
17032 KB |
Output is correct |
54 |
Correct |
570 ms |
16852 KB |
Output is correct |
55 |
Execution timed out |
2066 ms |
32380 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |