Submission #642416

# Submission time Handle Problem Language Result Execution time Memory
642416 2022-09-19T11:44:41 Z berr Joker (BOI20_joker) C++17
14 / 100
2000 ms 31768 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=15; 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 9 ms 16724 KB Output is correct
4 Correct 8 ms 16724 KB Output is correct
5 Correct 9 ms 16716 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 10 ms 16724 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 9 ms 16724 KB Output is correct
11 Correct 11 ms 16724 KB Output is correct
12 Correct 14 ms 16724 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 10 ms 16724 KB Output is correct
15 Correct 10 ms 16724 KB Output is correct
16 Correct 11 ms 16764 KB Output is correct
17 Correct 11 ms 16724 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 16724 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16784 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 11 ms 16724 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
# 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 9 ms 16724 KB Output is correct
4 Correct 8 ms 16724 KB Output is correct
5 Correct 9 ms 16716 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 10 ms 16724 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 9 ms 16724 KB Output is correct
11 Correct 11 ms 16724 KB Output is correct
12 Correct 14 ms 16724 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 10 ms 16724 KB Output is correct
15 Correct 10 ms 16724 KB Output is correct
16 Correct 11 ms 16764 KB Output is correct
17 Correct 11 ms 16724 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 16724 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16784 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 11 ms 16724 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 278 ms 16936 KB Output is correct
30 Correct 511 ms 16888 KB Output is correct
31 Correct 478 ms 16916 KB Output is correct
32 Correct 354 ms 16904 KB Output is correct
33 Correct 285 ms 16904 KB Output is correct
34 Correct 482 ms 16904 KB Output is correct
35 Correct 605 ms 16904 KB Output is correct
36 Correct 160 ms 16924 KB Output is correct
37 Correct 407 ms 17028 KB Output is correct
38 Correct 499 ms 16852 KB Output is correct
39 Correct 398 ms 16896 KB Output is correct
40 Correct 326 ms 16912 KB Output is correct
41 Correct 336 ms 16904 KB Output is correct
42 Correct 324 ms 16916 KB Output is correct
43 Correct 293 ms 16900 KB Output is correct
44 Correct 373 ms 16852 KB Output is correct
45 Correct 451 ms 16972 KB Output is correct
46 Correct 581 ms 16900 KB Output is correct
47 Correct 338 ms 17028 KB Output is correct
48 Correct 365 ms 16896 KB Output is correct
49 Correct 448 ms 17024 KB Output is correct
50 Correct 524 ms 16880 KB Output is correct
51 Correct 311 ms 16900 KB Output is correct
52 Correct 372 ms 16916 KB Output is correct
53 Correct 443 ms 16920 KB Output is correct
54 Correct 582 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 Incorrect 215 ms 28848 KB Output isn't correct
4 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 9 ms 16724 KB Output is correct
4 Correct 8 ms 16724 KB Output is correct
5 Correct 9 ms 16716 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 10 ms 16724 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 9 ms 16724 KB Output is correct
11 Correct 11 ms 16724 KB Output is correct
12 Correct 14 ms 16724 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 10 ms 16724 KB Output is correct
15 Correct 10 ms 16724 KB Output is correct
16 Correct 11 ms 16764 KB Output is correct
17 Correct 11 ms 16724 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 16724 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16784 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 11 ms 16724 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 Incorrect 215 ms 28848 KB Output isn't correct
30 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 9 ms 16724 KB Output is correct
4 Correct 8 ms 16724 KB Output is correct
5 Correct 9 ms 16716 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 10 ms 16724 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 9 ms 16724 KB Output is correct
11 Correct 11 ms 16724 KB Output is correct
12 Correct 14 ms 16724 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 10 ms 16724 KB Output is correct
15 Correct 10 ms 16724 KB Output is correct
16 Correct 11 ms 16764 KB Output is correct
17 Correct 11 ms 16724 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 16724 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16784 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 11 ms 16724 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 278 ms 16936 KB Output is correct
30 Correct 511 ms 16888 KB Output is correct
31 Correct 478 ms 16916 KB Output is correct
32 Correct 354 ms 16904 KB Output is correct
33 Correct 285 ms 16904 KB Output is correct
34 Correct 482 ms 16904 KB Output is correct
35 Correct 605 ms 16904 KB Output is correct
36 Correct 160 ms 16924 KB Output is correct
37 Correct 407 ms 17028 KB Output is correct
38 Correct 499 ms 16852 KB Output is correct
39 Correct 398 ms 16896 KB Output is correct
40 Correct 326 ms 16912 KB Output is correct
41 Correct 336 ms 16904 KB Output is correct
42 Correct 324 ms 16916 KB Output is correct
43 Correct 293 ms 16900 KB Output is correct
44 Correct 373 ms 16852 KB Output is correct
45 Correct 451 ms 16972 KB Output is correct
46 Correct 581 ms 16900 KB Output is correct
47 Correct 338 ms 17028 KB Output is correct
48 Correct 365 ms 16896 KB Output is correct
49 Correct 448 ms 17024 KB Output is correct
50 Correct 524 ms 16880 KB Output is correct
51 Correct 311 ms 16900 KB Output is correct
52 Correct 372 ms 16916 KB Output is correct
53 Correct 443 ms 16920 KB Output is correct
54 Correct 582 ms 16972 KB Output is correct
55 Execution timed out 2087 ms 31768 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 9 ms 16724 KB Output is correct
4 Correct 8 ms 16724 KB Output is correct
5 Correct 9 ms 16716 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 8 ms 16724 KB Output is correct
8 Correct 10 ms 16724 KB Output is correct
9 Correct 10 ms 16724 KB Output is correct
10 Correct 9 ms 16724 KB Output is correct
11 Correct 11 ms 16724 KB Output is correct
12 Correct 14 ms 16724 KB Output is correct
13 Correct 8 ms 16724 KB Output is correct
14 Correct 10 ms 16724 KB Output is correct
15 Correct 10 ms 16724 KB Output is correct
16 Correct 11 ms 16764 KB Output is correct
17 Correct 11 ms 16724 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 16724 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16784 KB Output is correct
24 Correct 10 ms 16724 KB Output is correct
25 Correct 11 ms 16724 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 278 ms 16936 KB Output is correct
30 Correct 511 ms 16888 KB Output is correct
31 Correct 478 ms 16916 KB Output is correct
32 Correct 354 ms 16904 KB Output is correct
33 Correct 285 ms 16904 KB Output is correct
34 Correct 482 ms 16904 KB Output is correct
35 Correct 605 ms 16904 KB Output is correct
36 Correct 160 ms 16924 KB Output is correct
37 Correct 407 ms 17028 KB Output is correct
38 Correct 499 ms 16852 KB Output is correct
39 Correct 398 ms 16896 KB Output is correct
40 Correct 326 ms 16912 KB Output is correct
41 Correct 336 ms 16904 KB Output is correct
42 Correct 324 ms 16916 KB Output is correct
43 Correct 293 ms 16900 KB Output is correct
44 Correct 373 ms 16852 KB Output is correct
45 Correct 451 ms 16972 KB Output is correct
46 Correct 581 ms 16900 KB Output is correct
47 Correct 338 ms 17028 KB Output is correct
48 Correct 365 ms 16896 KB Output is correct
49 Correct 448 ms 17024 KB Output is correct
50 Correct 524 ms 16880 KB Output is correct
51 Correct 311 ms 16900 KB Output is correct
52 Correct 372 ms 16916 KB Output is correct
53 Correct 443 ms 16920 KB Output is correct
54 Correct 582 ms 16972 KB Output is correct
55 Incorrect 215 ms 28848 KB Output isn't correct
56 Halted 0 ms 0 KB -