Submission #642417

# Submission time Handle Problem Language Result Execution time Memory
642417 2022-09-19T11:45:41 Z berr Joker (BOI20_joker) C++17
39 / 100
2000 ms 32588 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=18; 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";
        }
    }
}
    
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 7 ms 16724 KB Output is correct
4 Correct 9 ms 16724 KB Output is correct
5 Correct 7 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16740 KB Output is correct
8 Correct 11 ms 16720 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 10 ms 16724 KB Output is correct
11 Correct 11 ms 16784 KB Output is correct
12 Correct 13 ms 16724 KB Output is correct
13 Correct 10 ms 16728 KB Output is correct
14 Correct 10 ms 16732 KB Output is correct
15 Correct 10 ms 16692 KB Output is correct
16 Correct 10 ms 16724 KB Output is correct
17 Correct 9 ms 16724 KB Output is correct
18 Correct 9 ms 16684 KB Output is correct
19 Correct 9 ms 16724 KB Output is correct
20 Correct 9 ms 16764 KB Output is correct
21 Correct 12 ms 16724 KB Output is correct
22 Correct 10 ms 16724 KB Output is correct
23 Correct 9 ms 16768 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 10 ms 16724 KB Output is correct
26 Correct 12 ms 16980 KB Output is correct
27 Correct 10 ms 16724 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 7 ms 16724 KB Output is correct
4 Correct 9 ms 16724 KB Output is correct
5 Correct 7 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16740 KB Output is correct
8 Correct 11 ms 16720 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 10 ms 16724 KB Output is correct
11 Correct 11 ms 16784 KB Output is correct
12 Correct 13 ms 16724 KB Output is correct
13 Correct 10 ms 16728 KB Output is correct
14 Correct 10 ms 16732 KB Output is correct
15 Correct 10 ms 16692 KB Output is correct
16 Correct 10 ms 16724 KB Output is correct
17 Correct 9 ms 16724 KB Output is correct
18 Correct 9 ms 16684 KB Output is correct
19 Correct 9 ms 16724 KB Output is correct
20 Correct 9 ms 16764 KB Output is correct
21 Correct 12 ms 16724 KB Output is correct
22 Correct 10 ms 16724 KB Output is correct
23 Correct 9 ms 16768 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 10 ms 16724 KB Output is correct
26 Correct 12 ms 16980 KB Output is correct
27 Correct 10 ms 16724 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 277 ms 16808 KB Output is correct
30 Correct 509 ms 16880 KB Output is correct
31 Correct 472 ms 16912 KB Output is correct
32 Correct 357 ms 16912 KB Output is correct
33 Correct 275 ms 16912 KB Output is correct
34 Correct 490 ms 16908 KB Output is correct
35 Correct 589 ms 16904 KB Output is correct
36 Correct 163 ms 16852 KB Output is correct
37 Correct 389 ms 16904 KB Output is correct
38 Correct 502 ms 16988 KB Output is correct
39 Correct 394 ms 16892 KB Output is correct
40 Correct 331 ms 16832 KB Output is correct
41 Correct 324 ms 16924 KB Output is correct
42 Correct 327 ms 16972 KB Output is correct
43 Correct 281 ms 16852 KB Output is correct
44 Correct 382 ms 16972 KB Output is correct
45 Correct 447 ms 16908 KB Output is correct
46 Correct 582 ms 16972 KB Output is correct
47 Correct 332 ms 16852 KB Output is correct
48 Correct 368 ms 17028 KB Output is correct
49 Correct 436 ms 16852 KB Output is correct
50 Correct 523 ms 16884 KB Output is correct
51 Correct 309 ms 16852 KB Output is correct
52 Correct 376 ms 16920 KB Output is correct
53 Correct 443 ms 16912 KB Output is correct
54 Correct 586 ms 16972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 220 ms 30616 KB Output is correct
4 Correct 420 ms 29976 KB Output is correct
5 Correct 268 ms 28492 KB Output is correct
6 Correct 356 ms 30576 KB Output is correct
7 Correct 334 ms 30480 KB Output is correct
8 Correct 283 ms 30796 KB Output is correct
9 Correct 374 ms 31188 KB Output is correct
10 Correct 522 ms 28912 KB Output is correct
11 Correct 303 ms 29532 KB Output is correct
12 Correct 369 ms 28124 KB Output is correct
13 Correct 173 ms 29132 KB Output is correct
14 Correct 302 ms 30580 KB Output is correct
15 Correct 459 ms 30416 KB Output is correct
16 Correct 463 ms 28744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 7 ms 16724 KB Output is correct
4 Correct 9 ms 16724 KB Output is correct
5 Correct 7 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16740 KB Output is correct
8 Correct 11 ms 16720 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 10 ms 16724 KB Output is correct
11 Correct 11 ms 16784 KB Output is correct
12 Correct 13 ms 16724 KB Output is correct
13 Correct 10 ms 16728 KB Output is correct
14 Correct 10 ms 16732 KB Output is correct
15 Correct 10 ms 16692 KB Output is correct
16 Correct 10 ms 16724 KB Output is correct
17 Correct 9 ms 16724 KB Output is correct
18 Correct 9 ms 16684 KB Output is correct
19 Correct 9 ms 16724 KB Output is correct
20 Correct 9 ms 16764 KB Output is correct
21 Correct 12 ms 16724 KB Output is correct
22 Correct 10 ms 16724 KB Output is correct
23 Correct 9 ms 16768 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 10 ms 16724 KB Output is correct
26 Correct 12 ms 16980 KB Output is correct
27 Correct 10 ms 16724 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 220 ms 30616 KB Output is correct
30 Correct 420 ms 29976 KB Output is correct
31 Correct 268 ms 28492 KB Output is correct
32 Correct 356 ms 30576 KB Output is correct
33 Correct 334 ms 30480 KB Output is correct
34 Correct 283 ms 30796 KB Output is correct
35 Correct 374 ms 31188 KB Output is correct
36 Correct 522 ms 28912 KB Output is correct
37 Correct 303 ms 29532 KB Output is correct
38 Correct 369 ms 28124 KB Output is correct
39 Correct 173 ms 29132 KB Output is correct
40 Correct 302 ms 30580 KB Output is correct
41 Correct 459 ms 30416 KB Output is correct
42 Correct 463 ms 28744 KB Output is correct
43 Execution timed out 2086 ms 32588 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 7 ms 16724 KB Output is correct
4 Correct 9 ms 16724 KB Output is correct
5 Correct 7 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16740 KB Output is correct
8 Correct 11 ms 16720 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 10 ms 16724 KB Output is correct
11 Correct 11 ms 16784 KB Output is correct
12 Correct 13 ms 16724 KB Output is correct
13 Correct 10 ms 16728 KB Output is correct
14 Correct 10 ms 16732 KB Output is correct
15 Correct 10 ms 16692 KB Output is correct
16 Correct 10 ms 16724 KB Output is correct
17 Correct 9 ms 16724 KB Output is correct
18 Correct 9 ms 16684 KB Output is correct
19 Correct 9 ms 16724 KB Output is correct
20 Correct 9 ms 16764 KB Output is correct
21 Correct 12 ms 16724 KB Output is correct
22 Correct 10 ms 16724 KB Output is correct
23 Correct 9 ms 16768 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 10 ms 16724 KB Output is correct
26 Correct 12 ms 16980 KB Output is correct
27 Correct 10 ms 16724 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 277 ms 16808 KB Output is correct
30 Correct 509 ms 16880 KB Output is correct
31 Correct 472 ms 16912 KB Output is correct
32 Correct 357 ms 16912 KB Output is correct
33 Correct 275 ms 16912 KB Output is correct
34 Correct 490 ms 16908 KB Output is correct
35 Correct 589 ms 16904 KB Output is correct
36 Correct 163 ms 16852 KB Output is correct
37 Correct 389 ms 16904 KB Output is correct
38 Correct 502 ms 16988 KB Output is correct
39 Correct 394 ms 16892 KB Output is correct
40 Correct 331 ms 16832 KB Output is correct
41 Correct 324 ms 16924 KB Output is correct
42 Correct 327 ms 16972 KB Output is correct
43 Correct 281 ms 16852 KB Output is correct
44 Correct 382 ms 16972 KB Output is correct
45 Correct 447 ms 16908 KB Output is correct
46 Correct 582 ms 16972 KB Output is correct
47 Correct 332 ms 16852 KB Output is correct
48 Correct 368 ms 17028 KB Output is correct
49 Correct 436 ms 16852 KB Output is correct
50 Correct 523 ms 16884 KB Output is correct
51 Correct 309 ms 16852 KB Output is correct
52 Correct 376 ms 16920 KB Output is correct
53 Correct 443 ms 16912 KB Output is correct
54 Correct 586 ms 16972 KB Output is correct
55 Execution timed out 2081 ms 31836 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 16724 KB Output is correct
2 Correct 7 ms 16724 KB Output is correct
3 Correct 7 ms 16724 KB Output is correct
4 Correct 9 ms 16724 KB Output is correct
5 Correct 7 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16740 KB Output is correct
8 Correct 11 ms 16720 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 10 ms 16724 KB Output is correct
11 Correct 11 ms 16784 KB Output is correct
12 Correct 13 ms 16724 KB Output is correct
13 Correct 10 ms 16728 KB Output is correct
14 Correct 10 ms 16732 KB Output is correct
15 Correct 10 ms 16692 KB Output is correct
16 Correct 10 ms 16724 KB Output is correct
17 Correct 9 ms 16724 KB Output is correct
18 Correct 9 ms 16684 KB Output is correct
19 Correct 9 ms 16724 KB Output is correct
20 Correct 9 ms 16764 KB Output is correct
21 Correct 12 ms 16724 KB Output is correct
22 Correct 10 ms 16724 KB Output is correct
23 Correct 9 ms 16768 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 10 ms 16724 KB Output is correct
26 Correct 12 ms 16980 KB Output is correct
27 Correct 10 ms 16724 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 277 ms 16808 KB Output is correct
30 Correct 509 ms 16880 KB Output is correct
31 Correct 472 ms 16912 KB Output is correct
32 Correct 357 ms 16912 KB Output is correct
33 Correct 275 ms 16912 KB Output is correct
34 Correct 490 ms 16908 KB Output is correct
35 Correct 589 ms 16904 KB Output is correct
36 Correct 163 ms 16852 KB Output is correct
37 Correct 389 ms 16904 KB Output is correct
38 Correct 502 ms 16988 KB Output is correct
39 Correct 394 ms 16892 KB Output is correct
40 Correct 331 ms 16832 KB Output is correct
41 Correct 324 ms 16924 KB Output is correct
42 Correct 327 ms 16972 KB Output is correct
43 Correct 281 ms 16852 KB Output is correct
44 Correct 382 ms 16972 KB Output is correct
45 Correct 447 ms 16908 KB Output is correct
46 Correct 582 ms 16972 KB Output is correct
47 Correct 332 ms 16852 KB Output is correct
48 Correct 368 ms 17028 KB Output is correct
49 Correct 436 ms 16852 KB Output is correct
50 Correct 523 ms 16884 KB Output is correct
51 Correct 309 ms 16852 KB Output is correct
52 Correct 376 ms 16920 KB Output is correct
53 Correct 443 ms 16912 KB Output is correct
54 Correct 586 ms 16972 KB Output is correct
55 Correct 220 ms 30616 KB Output is correct
56 Correct 420 ms 29976 KB Output is correct
57 Correct 268 ms 28492 KB Output is correct
58 Correct 356 ms 30576 KB Output is correct
59 Correct 334 ms 30480 KB Output is correct
60 Correct 283 ms 30796 KB Output is correct
61 Correct 374 ms 31188 KB Output is correct
62 Correct 522 ms 28912 KB Output is correct
63 Correct 303 ms 29532 KB Output is correct
64 Correct 369 ms 28124 KB Output is correct
65 Correct 173 ms 29132 KB Output is correct
66 Correct 302 ms 30580 KB Output is correct
67 Correct 459 ms 30416 KB Output is correct
68 Correct 463 ms 28744 KB Output is correct
69 Execution timed out 2086 ms 32588 KB Time limit exceeded
70 Halted 0 ms 0 KB -