답안 #1100581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100581 2024-10-14T09:22:55 Z vivkostov Joker (BOI20_joker) C++14
14 / 100
2000 ms 6372 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
struct cell
{
    int a,b;
};
int n,m,q,a[200005],b[200005],l,r,lead[200005],sw[200005],sz[200005],lamp;
stack<cell>s;
void prec()
{
    for(int i=1;i<=n;i++)
    {
        lead[i]=i;
        sz[i]=1;
        sw[i]=0;
    }
}
int get_lead(int beg)
{
    if(lead[beg]==beg)return beg;
    return get_lead(lead[beg]);
}
int get_br(int beg,int br)
{
    if(lead[beg]==beg)return br;
    return get_br(lead[beg],br+sw[beg]);
}
void add(int a,int b)
{
    int la=get_lead(a);
    int lb=get_lead(b);
    if(la==lb)
    {
        if(get_br(a,0)%2==get_br(b,0)%2)lamp=1;
        return;
    }
    if(sz[la]<sz[lb])
    {
        swap(la,lb);
        swap(a,b);
    }
    lead[lb]=la;
    sz[la]+=sz[lb];
    if(get_br(a,0)%2==get_br(b,0)%2)sw[lb]++;
}
void rem()
{
    int a=s.top().a;
    int b=s.top().b;
    s.pop();
    sz[a]-=sz[b];
    lead[b]=b;
}
void read()
{
    cin>>n>>m>>q;
    prec();
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=q;i++)
    {
        cin>>l>>r;
        for(int j=1;j<l;j++)
        {
            add(a[j],b[j]);
            /*for(int z=1;z<=n;z++)
            {
                cout<<lead[z]<<" "<<sz[z]<<" "<<sw[z]<<endl;
            }
            cout<<endl;
            */
        }
        for(int j=r+1;j<=m;j++)
        {
            add(a[j],b[j]);
            /*for(int z=1;z<=n;z++)
            {
                cout<<lead[z]<<" "<<sz[z]<<" "<<sw[z]<<endl;
            }
            */
        }
        if(lamp)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        prec();
        lamp=0;
    }
}
int main()
{
    speed();
    read();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2524 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2400 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2524 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2400 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Correct 16 ms 2384 KB Output is correct
30 Correct 28 ms 2532 KB Output is correct
31 Correct 34 ms 2396 KB Output is correct
32 Correct 28 ms 2580 KB Output is correct
33 Correct 24 ms 2760 KB Output is correct
34 Correct 29 ms 2560 KB Output is correct
35 Correct 32 ms 2584 KB Output is correct
36 Correct 16 ms 2384 KB Output is correct
37 Correct 31 ms 2384 KB Output is correct
38 Correct 26 ms 2384 KB Output is correct
39 Correct 33 ms 2384 KB Output is correct
40 Correct 25 ms 2384 KB Output is correct
41 Correct 25 ms 2384 KB Output is correct
42 Correct 23 ms 2556 KB Output is correct
43 Correct 36 ms 2552 KB Output is correct
44 Correct 39 ms 2384 KB Output is correct
45 Correct 41 ms 2384 KB Output is correct
46 Correct 37 ms 2384 KB Output is correct
47 Correct 24 ms 2600 KB Output is correct
48 Correct 28 ms 2384 KB Output is correct
49 Correct 27 ms 2384 KB Output is correct
50 Correct 29 ms 2384 KB Output is correct
51 Correct 27 ms 2384 KB Output is correct
52 Correct 27 ms 2384 KB Output is correct
53 Correct 28 ms 2384 KB Output is correct
54 Correct 32 ms 2596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Execution timed out 2075 ms 4188 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2524 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2400 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Execution timed out 2075 ms 4188 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2524 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2400 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Correct 16 ms 2384 KB Output is correct
30 Correct 28 ms 2532 KB Output is correct
31 Correct 34 ms 2396 KB Output is correct
32 Correct 28 ms 2580 KB Output is correct
33 Correct 24 ms 2760 KB Output is correct
34 Correct 29 ms 2560 KB Output is correct
35 Correct 32 ms 2584 KB Output is correct
36 Correct 16 ms 2384 KB Output is correct
37 Correct 31 ms 2384 KB Output is correct
38 Correct 26 ms 2384 KB Output is correct
39 Correct 33 ms 2384 KB Output is correct
40 Correct 25 ms 2384 KB Output is correct
41 Correct 25 ms 2384 KB Output is correct
42 Correct 23 ms 2556 KB Output is correct
43 Correct 36 ms 2552 KB Output is correct
44 Correct 39 ms 2384 KB Output is correct
45 Correct 41 ms 2384 KB Output is correct
46 Correct 37 ms 2384 KB Output is correct
47 Correct 24 ms 2600 KB Output is correct
48 Correct 28 ms 2384 KB Output is correct
49 Correct 27 ms 2384 KB Output is correct
50 Correct 29 ms 2384 KB Output is correct
51 Correct 27 ms 2384 KB Output is correct
52 Correct 27 ms 2384 KB Output is correct
53 Correct 28 ms 2384 KB Output is correct
54 Correct 32 ms 2596 KB Output is correct
55 Execution timed out 2044 ms 6372 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2524 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2400 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2552 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Correct 16 ms 2384 KB Output is correct
30 Correct 28 ms 2532 KB Output is correct
31 Correct 34 ms 2396 KB Output is correct
32 Correct 28 ms 2580 KB Output is correct
33 Correct 24 ms 2760 KB Output is correct
34 Correct 29 ms 2560 KB Output is correct
35 Correct 32 ms 2584 KB Output is correct
36 Correct 16 ms 2384 KB Output is correct
37 Correct 31 ms 2384 KB Output is correct
38 Correct 26 ms 2384 KB Output is correct
39 Correct 33 ms 2384 KB Output is correct
40 Correct 25 ms 2384 KB Output is correct
41 Correct 25 ms 2384 KB Output is correct
42 Correct 23 ms 2556 KB Output is correct
43 Correct 36 ms 2552 KB Output is correct
44 Correct 39 ms 2384 KB Output is correct
45 Correct 41 ms 2384 KB Output is correct
46 Correct 37 ms 2384 KB Output is correct
47 Correct 24 ms 2600 KB Output is correct
48 Correct 28 ms 2384 KB Output is correct
49 Correct 27 ms 2384 KB Output is correct
50 Correct 29 ms 2384 KB Output is correct
51 Correct 27 ms 2384 KB Output is correct
52 Correct 27 ms 2384 KB Output is correct
53 Correct 28 ms 2384 KB Output is correct
54 Correct 32 ms 2596 KB Output is correct
55 Execution timed out 2075 ms 4188 KB Time limit exceeded
56 Halted 0 ms 0 KB -