Submission #649786

# Submission time Handle Problem Language Result Execution time Memory
649786 2022-10-11T10:54:13 Z DJeniUp Joker (BOI20_joker) C++17
6 / 100
2000 ms 14328 KB
#include "bits/stdc++.h"
//#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef long double ld;

#define fr first
#define sc second
#define pb push_back
#define INF 100000000007
#define endl '\n'
#define MOD 998244353
#define N 200007

ll n,m,q,p[N],t[N],res[N],h[N],f,k;

struct Q{
    ll l,r;
}o[N];

struct D{
    ll l,r;
}d[N];

set<ll>s;

ll P(ll x){
    if(p[x]==x)return x;
    return P(p[x]);
}

ll H(ll x){
    ll r1=0;
    while(p[x]!=x){
        r1+=h[x];
        x=p[x];
    }
    return r1;
}

void A(ll x,ll y){
    if(rand()%2)swap(x,y);
    ll x1=P(x);
    ll y1=P(y);
    h[x1]=H(x)+1+H(y);
    p[x1]=y1;
    return ;
}

int main(){
    
    cin>>n>>m>>q;
    //s.insert(0);
    for(int i=1;i<=m;i++){
        cin>>d[i].l>>d[i].r;
    }
    for(int i=1;i<=q;i++){
        cin>>o[i].l>>o[i].r;
        s.insert(o[i].l-1);
    }
    for(auto it:s){
        res[it]=0;
        for(int i=1;i<=n;i++){
            p[i]=i;
            h[i]=i;
        }
        for(int i=1;i<=it;i++){
            if(P(d[i].l)!=P(d[i].r)){
                A(d[i].l,d[i].r);
            }else if(H(d[i].l)%2==H(d[i].r)%2){
                res[it]=m+1;
            }
        }
        if(res[it]!=0)continue;
        for(int i=m;i>=it;i--){
            if(P(d[i].l)==P(d[i].r) && H(d[i].l)%2==H(d[i].r)%2){
                res[it]=i;
                break;
            }else if(P(d[i].l)!=P(d[i].r))A(d[i].l,d[i].r);
        }
    }
    
    for(int i=1;i<=q;i++){
        
        if(res[o[i].l-1]>o[i].r)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 304 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 304 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 308 KB Output is correct
29 Correct 37 ms 480 KB Output is correct
30 Correct 96 ms 520 KB Output is correct
31 Correct 222 ms 636 KB Output is correct
32 Correct 309 ms 512 KB Output is correct
33 Correct 382 ms 504 KB Output is correct
34 Correct 156 ms 588 KB Output is correct
35 Correct 144 ms 520 KB Output is correct
36 Correct 777 ms 516 KB Output is correct
37 Correct 76 ms 528 KB Output is correct
38 Correct 117 ms 636 KB Output is correct
39 Incorrect 142 ms 468 KB Output isn't correct
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 206 ms 8652 KB Output is correct
4 Correct 211 ms 13808 KB Output is correct
5 Correct 219 ms 14328 KB Output is correct
6 Correct 209 ms 12696 KB Output is correct
7 Correct 206 ms 12776 KB Output is correct
8 Execution timed out 2065 ms 10736 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 304 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 308 KB Output is correct
29 Correct 206 ms 8652 KB Output is correct
30 Correct 211 ms 13808 KB Output is correct
31 Correct 219 ms 14328 KB Output is correct
32 Correct 209 ms 12696 KB Output is correct
33 Correct 206 ms 12776 KB Output is correct
34 Execution timed out 2065 ms 10736 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 304 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 308 KB Output is correct
29 Correct 37 ms 480 KB Output is correct
30 Correct 96 ms 520 KB Output is correct
31 Correct 222 ms 636 KB Output is correct
32 Correct 309 ms 512 KB Output is correct
33 Correct 382 ms 504 KB Output is correct
34 Correct 156 ms 588 KB Output is correct
35 Correct 144 ms 520 KB Output is correct
36 Correct 777 ms 516 KB Output is correct
37 Correct 76 ms 528 KB Output is correct
38 Correct 117 ms 636 KB Output is correct
39 Incorrect 142 ms 468 KB Output isn't correct
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 304 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 304 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 308 KB Output is correct
29 Correct 37 ms 480 KB Output is correct
30 Correct 96 ms 520 KB Output is correct
31 Correct 222 ms 636 KB Output is correct
32 Correct 309 ms 512 KB Output is correct
33 Correct 382 ms 504 KB Output is correct
34 Correct 156 ms 588 KB Output is correct
35 Correct 144 ms 520 KB Output is correct
36 Correct 777 ms 516 KB Output is correct
37 Correct 76 ms 528 KB Output is correct
38 Correct 117 ms 636 KB Output is correct
39 Incorrect 142 ms 468 KB Output isn't correct
40 Halted 0 ms 0 KB -