Submission #642415

# Submission time Handle Problem Language Result Execution time Memory
642415 2022-09-19T11:43:35 Z berr Joker (BOI20_joker) C++17
14 / 100
2000 ms 31780 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=14; 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 8 ms 16724 KB Output is correct
2 Correct 8 ms 16700 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 8 ms 16696 KB Output is correct
5 Correct 9 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16724 KB Output is correct
8 Correct 11 ms 16724 KB Output is correct
9 Correct 11 ms 16724 KB Output is correct
10 Correct 11 ms 16768 KB Output is correct
11 Correct 13 ms 16724 KB Output is correct
12 Correct 11 ms 16668 KB Output is correct
13 Correct 10 ms 16724 KB Output is correct
14 Correct 11 ms 16668 KB Output is correct
15 Correct 11 ms 16704 KB Output is correct
16 Correct 10 ms 16688 KB Output is correct
17 Correct 11 ms 16744 KB Output is correct
18 Correct 10 ms 16724 KB Output is correct
19 Correct 10 ms 16724 KB Output is correct
20 Correct 10 ms 16724 KB Output is correct
21 Correct 12 ms 16776 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16724 KB Output is correct
24 Correct 11 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 16668 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 16724 KB Output is correct
2 Correct 8 ms 16700 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 8 ms 16696 KB Output is correct
5 Correct 9 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16724 KB Output is correct
8 Correct 11 ms 16724 KB Output is correct
9 Correct 11 ms 16724 KB Output is correct
10 Correct 11 ms 16768 KB Output is correct
11 Correct 13 ms 16724 KB Output is correct
12 Correct 11 ms 16668 KB Output is correct
13 Correct 10 ms 16724 KB Output is correct
14 Correct 11 ms 16668 KB Output is correct
15 Correct 11 ms 16704 KB Output is correct
16 Correct 10 ms 16688 KB Output is correct
17 Correct 11 ms 16744 KB Output is correct
18 Correct 10 ms 16724 KB Output is correct
19 Correct 10 ms 16724 KB Output is correct
20 Correct 10 ms 16724 KB Output is correct
21 Correct 12 ms 16776 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16724 KB Output is correct
24 Correct 11 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 16668 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 281 ms 16816 KB Output is correct
30 Correct 526 ms 16980 KB Output is correct
31 Correct 478 ms 16912 KB Output is correct
32 Correct 359 ms 16904 KB Output is correct
33 Correct 272 ms 16900 KB Output is correct
34 Correct 496 ms 17104 KB Output is correct
35 Correct 609 ms 17028 KB Output is correct
36 Correct 162 ms 16928 KB Output is correct
37 Correct 392 ms 16904 KB Output is correct
38 Correct 490 ms 16900 KB Output is correct
39 Correct 395 ms 17024 KB Output is correct
40 Correct 328 ms 16928 KB Output is correct
41 Correct 328 ms 16852 KB Output is correct
42 Correct 328 ms 16924 KB Output is correct
43 Correct 282 ms 16852 KB Output is correct
44 Correct 379 ms 16972 KB Output is correct
45 Correct 446 ms 16852 KB Output is correct
46 Correct 591 ms 16972 KB Output is correct
47 Correct 337 ms 16896 KB Output is correct
48 Correct 359 ms 16904 KB Output is correct
49 Correct 434 ms 16852 KB Output is correct
50 Correct 521 ms 16880 KB Output is correct
51 Correct 316 ms 16904 KB Output is correct
52 Correct 374 ms 16908 KB Output is correct
53 Correct 445 ms 16920 KB Output is correct
54 Correct 618 ms 16852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 16724 KB Output is correct
2 Correct 8 ms 16700 KB Output is correct
3 Incorrect 188 ms 29644 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 16724 KB Output is correct
2 Correct 8 ms 16700 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 8 ms 16696 KB Output is correct
5 Correct 9 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16724 KB Output is correct
8 Correct 11 ms 16724 KB Output is correct
9 Correct 11 ms 16724 KB Output is correct
10 Correct 11 ms 16768 KB Output is correct
11 Correct 13 ms 16724 KB Output is correct
12 Correct 11 ms 16668 KB Output is correct
13 Correct 10 ms 16724 KB Output is correct
14 Correct 11 ms 16668 KB Output is correct
15 Correct 11 ms 16704 KB Output is correct
16 Correct 10 ms 16688 KB Output is correct
17 Correct 11 ms 16744 KB Output is correct
18 Correct 10 ms 16724 KB Output is correct
19 Correct 10 ms 16724 KB Output is correct
20 Correct 10 ms 16724 KB Output is correct
21 Correct 12 ms 16776 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16724 KB Output is correct
24 Correct 11 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 16668 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Incorrect 188 ms 29644 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 16724 KB Output is correct
2 Correct 8 ms 16700 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 8 ms 16696 KB Output is correct
5 Correct 9 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16724 KB Output is correct
8 Correct 11 ms 16724 KB Output is correct
9 Correct 11 ms 16724 KB Output is correct
10 Correct 11 ms 16768 KB Output is correct
11 Correct 13 ms 16724 KB Output is correct
12 Correct 11 ms 16668 KB Output is correct
13 Correct 10 ms 16724 KB Output is correct
14 Correct 11 ms 16668 KB Output is correct
15 Correct 11 ms 16704 KB Output is correct
16 Correct 10 ms 16688 KB Output is correct
17 Correct 11 ms 16744 KB Output is correct
18 Correct 10 ms 16724 KB Output is correct
19 Correct 10 ms 16724 KB Output is correct
20 Correct 10 ms 16724 KB Output is correct
21 Correct 12 ms 16776 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16724 KB Output is correct
24 Correct 11 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 16668 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 281 ms 16816 KB Output is correct
30 Correct 526 ms 16980 KB Output is correct
31 Correct 478 ms 16912 KB Output is correct
32 Correct 359 ms 16904 KB Output is correct
33 Correct 272 ms 16900 KB Output is correct
34 Correct 496 ms 17104 KB Output is correct
35 Correct 609 ms 17028 KB Output is correct
36 Correct 162 ms 16928 KB Output is correct
37 Correct 392 ms 16904 KB Output is correct
38 Correct 490 ms 16900 KB Output is correct
39 Correct 395 ms 17024 KB Output is correct
40 Correct 328 ms 16928 KB Output is correct
41 Correct 328 ms 16852 KB Output is correct
42 Correct 328 ms 16924 KB Output is correct
43 Correct 282 ms 16852 KB Output is correct
44 Correct 379 ms 16972 KB Output is correct
45 Correct 446 ms 16852 KB Output is correct
46 Correct 591 ms 16972 KB Output is correct
47 Correct 337 ms 16896 KB Output is correct
48 Correct 359 ms 16904 KB Output is correct
49 Correct 434 ms 16852 KB Output is correct
50 Correct 521 ms 16880 KB Output is correct
51 Correct 316 ms 16904 KB Output is correct
52 Correct 374 ms 16908 KB Output is correct
53 Correct 445 ms 16920 KB Output is correct
54 Correct 618 ms 16852 KB Output is correct
55 Execution timed out 2090 ms 31780 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 8 ms 16700 KB Output is correct
3 Correct 9 ms 16724 KB Output is correct
4 Correct 8 ms 16696 KB Output is correct
5 Correct 9 ms 16724 KB Output is correct
6 Correct 8 ms 16724 KB Output is correct
7 Correct 9 ms 16724 KB Output is correct
8 Correct 11 ms 16724 KB Output is correct
9 Correct 11 ms 16724 KB Output is correct
10 Correct 11 ms 16768 KB Output is correct
11 Correct 13 ms 16724 KB Output is correct
12 Correct 11 ms 16668 KB Output is correct
13 Correct 10 ms 16724 KB Output is correct
14 Correct 11 ms 16668 KB Output is correct
15 Correct 11 ms 16704 KB Output is correct
16 Correct 10 ms 16688 KB Output is correct
17 Correct 11 ms 16744 KB Output is correct
18 Correct 10 ms 16724 KB Output is correct
19 Correct 10 ms 16724 KB Output is correct
20 Correct 10 ms 16724 KB Output is correct
21 Correct 12 ms 16776 KB Output is correct
22 Correct 11 ms 16724 KB Output is correct
23 Correct 10 ms 16724 KB Output is correct
24 Correct 11 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 16668 KB Output is correct
28 Correct 11 ms 16724 KB Output is correct
29 Correct 281 ms 16816 KB Output is correct
30 Correct 526 ms 16980 KB Output is correct
31 Correct 478 ms 16912 KB Output is correct
32 Correct 359 ms 16904 KB Output is correct
33 Correct 272 ms 16900 KB Output is correct
34 Correct 496 ms 17104 KB Output is correct
35 Correct 609 ms 17028 KB Output is correct
36 Correct 162 ms 16928 KB Output is correct
37 Correct 392 ms 16904 KB Output is correct
38 Correct 490 ms 16900 KB Output is correct
39 Correct 395 ms 17024 KB Output is correct
40 Correct 328 ms 16928 KB Output is correct
41 Correct 328 ms 16852 KB Output is correct
42 Correct 328 ms 16924 KB Output is correct
43 Correct 282 ms 16852 KB Output is correct
44 Correct 379 ms 16972 KB Output is correct
45 Correct 446 ms 16852 KB Output is correct
46 Correct 591 ms 16972 KB Output is correct
47 Correct 337 ms 16896 KB Output is correct
48 Correct 359 ms 16904 KB Output is correct
49 Correct 434 ms 16852 KB Output is correct
50 Correct 521 ms 16880 KB Output is correct
51 Correct 316 ms 16904 KB Output is correct
52 Correct 374 ms 16908 KB Output is correct
53 Correct 445 ms 16920 KB Output is correct
54 Correct 618 ms 16852 KB Output is correct
55 Incorrect 188 ms 29644 KB Output isn't correct
56 Halted 0 ms 0 KB -