Submission #313927

# Submission time Handle Problem Language Result Execution time Memory
313927 2020-10-17T10:25:53 Z vipghn2003 Joker (BOI20_joker) C++14
14 / 100
2000 ms 14576 KB
#include<bits/stdc++.h>

using namespace std;

const int N=2e5+5;
int n,m,q,p[N],a[N],u[N],v[N];
vector<int>comp[N];
bool kt;

int Find(int u)
{
    if(u==p[u]) return u;
    return p[u]=Find(p[u]);
}

void Union(int u,int v)
{
    bool same=false;
    if(a[u]==a[v]) same=true;
    int x=Find(u);
    int y=Find(v);
    if(x==y&&same) kt=false;
    if(x==y) return ;
    if(comp[x].size()>comp[y].size()) swap(x,y);
    p[x]=y;
    for(auto&node:comp[x])
    {
        comp[y].push_back(node);
        if(same) a[node]^=1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++) cin>>u[i]>>v[i];
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        for(int i=1;i<=n;i++)
        {
            p[i]=i;
            a[i]=0;
            comp[i].clear();
            comp[i].push_back(i);
        }
        kt=true;
        for(int i=1;i<l;i++) Union(u[i],v[i]);
        for(int i=m;i>r;i--) Union(u[i],v[i]);
        if(kt) cout<<"NO"<<'\n';
        else cout<<"YES"<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4992 KB Output is correct
8 Correct 5 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 5 ms 4992 KB Output is correct
11 Correct 5 ms 5120 KB Output is correct
12 Correct 5 ms 5120 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 5 ms 5120 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 4 ms 4992 KB Output is correct
18 Correct 4 ms 4992 KB Output is correct
19 Correct 5 ms 5120 KB Output is correct
20 Correct 4 ms 4992 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 5 ms 5248 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 5 ms 5120 KB Output is correct
25 Correct 5 ms 4992 KB Output is correct
26 Correct 4 ms 4992 KB Output is correct
27 Correct 4 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4992 KB Output is correct
8 Correct 5 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 5 ms 4992 KB Output is correct
11 Correct 5 ms 5120 KB Output is correct
12 Correct 5 ms 5120 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 5 ms 5120 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 4 ms 4992 KB Output is correct
18 Correct 4 ms 4992 KB Output is correct
19 Correct 5 ms 5120 KB Output is correct
20 Correct 4 ms 4992 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 5 ms 5248 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 5 ms 5120 KB Output is correct
25 Correct 5 ms 4992 KB Output is correct
26 Correct 4 ms 4992 KB Output is correct
27 Correct 4 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Correct 101 ms 5272 KB Output is correct
30 Correct 128 ms 5368 KB Output is correct
31 Correct 122 ms 5328 KB Output is correct
32 Correct 92 ms 5248 KB Output is correct
33 Correct 75 ms 5244 KB Output is correct
34 Correct 132 ms 5376 KB Output is correct
35 Correct 139 ms 5368 KB Output is correct
36 Correct 71 ms 5240 KB Output is correct
37 Correct 132 ms 5248 KB Output is correct
38 Correct 156 ms 5248 KB Output is correct
39 Correct 100 ms 5248 KB Output is correct
40 Correct 88 ms 5240 KB Output is correct
41 Correct 86 ms 5248 KB Output is correct
42 Correct 86 ms 5240 KB Output is correct
43 Correct 87 ms 5240 KB Output is correct
44 Correct 120 ms 5248 KB Output is correct
45 Correct 160 ms 5368 KB Output is correct
46 Correct 184 ms 5368 KB Output is correct
47 Correct 75 ms 5240 KB Output is correct
48 Correct 90 ms 5240 KB Output is correct
49 Correct 108 ms 5324 KB Output is correct
50 Correct 127 ms 5248 KB Output is correct
51 Correct 72 ms 5240 KB Output is correct
52 Correct 92 ms 5240 KB Output is correct
53 Correct 111 ms 5248 KB Output is correct
54 Correct 136 ms 5248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Execution timed out 2093 ms 14068 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4992 KB Output is correct
8 Correct 5 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 5 ms 4992 KB Output is correct
11 Correct 5 ms 5120 KB Output is correct
12 Correct 5 ms 5120 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 5 ms 5120 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 4 ms 4992 KB Output is correct
18 Correct 4 ms 4992 KB Output is correct
19 Correct 5 ms 5120 KB Output is correct
20 Correct 4 ms 4992 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 5 ms 5248 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 5 ms 5120 KB Output is correct
25 Correct 5 ms 4992 KB Output is correct
26 Correct 4 ms 4992 KB Output is correct
27 Correct 4 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Execution timed out 2093 ms 14068 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4992 KB Output is correct
8 Correct 5 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 5 ms 4992 KB Output is correct
11 Correct 5 ms 5120 KB Output is correct
12 Correct 5 ms 5120 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 5 ms 5120 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 4 ms 4992 KB Output is correct
18 Correct 4 ms 4992 KB Output is correct
19 Correct 5 ms 5120 KB Output is correct
20 Correct 4 ms 4992 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 5 ms 5248 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 5 ms 5120 KB Output is correct
25 Correct 5 ms 4992 KB Output is correct
26 Correct 4 ms 4992 KB Output is correct
27 Correct 4 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Correct 101 ms 5272 KB Output is correct
30 Correct 128 ms 5368 KB Output is correct
31 Correct 122 ms 5328 KB Output is correct
32 Correct 92 ms 5248 KB Output is correct
33 Correct 75 ms 5244 KB Output is correct
34 Correct 132 ms 5376 KB Output is correct
35 Correct 139 ms 5368 KB Output is correct
36 Correct 71 ms 5240 KB Output is correct
37 Correct 132 ms 5248 KB Output is correct
38 Correct 156 ms 5248 KB Output is correct
39 Correct 100 ms 5248 KB Output is correct
40 Correct 88 ms 5240 KB Output is correct
41 Correct 86 ms 5248 KB Output is correct
42 Correct 86 ms 5240 KB Output is correct
43 Correct 87 ms 5240 KB Output is correct
44 Correct 120 ms 5248 KB Output is correct
45 Correct 160 ms 5368 KB Output is correct
46 Correct 184 ms 5368 KB Output is correct
47 Correct 75 ms 5240 KB Output is correct
48 Correct 90 ms 5240 KB Output is correct
49 Correct 108 ms 5324 KB Output is correct
50 Correct 127 ms 5248 KB Output is correct
51 Correct 72 ms 5240 KB Output is correct
52 Correct 92 ms 5240 KB Output is correct
53 Correct 111 ms 5248 KB Output is correct
54 Correct 136 ms 5248 KB Output is correct
55 Execution timed out 2083 ms 14576 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 4 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4992 KB Output is correct
8 Correct 5 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 5 ms 4992 KB Output is correct
11 Correct 5 ms 5120 KB Output is correct
12 Correct 5 ms 5120 KB Output is correct
13 Correct 4 ms 4992 KB Output is correct
14 Correct 5 ms 5120 KB Output is correct
15 Correct 5 ms 5120 KB Output is correct
16 Correct 5 ms 5120 KB Output is correct
17 Correct 4 ms 4992 KB Output is correct
18 Correct 4 ms 4992 KB Output is correct
19 Correct 5 ms 5120 KB Output is correct
20 Correct 4 ms 4992 KB Output is correct
21 Correct 5 ms 5120 KB Output is correct
22 Correct 5 ms 5248 KB Output is correct
23 Correct 4 ms 4992 KB Output is correct
24 Correct 5 ms 5120 KB Output is correct
25 Correct 5 ms 4992 KB Output is correct
26 Correct 4 ms 4992 KB Output is correct
27 Correct 4 ms 5120 KB Output is correct
28 Correct 5 ms 5120 KB Output is correct
29 Correct 101 ms 5272 KB Output is correct
30 Correct 128 ms 5368 KB Output is correct
31 Correct 122 ms 5328 KB Output is correct
32 Correct 92 ms 5248 KB Output is correct
33 Correct 75 ms 5244 KB Output is correct
34 Correct 132 ms 5376 KB Output is correct
35 Correct 139 ms 5368 KB Output is correct
36 Correct 71 ms 5240 KB Output is correct
37 Correct 132 ms 5248 KB Output is correct
38 Correct 156 ms 5248 KB Output is correct
39 Correct 100 ms 5248 KB Output is correct
40 Correct 88 ms 5240 KB Output is correct
41 Correct 86 ms 5248 KB Output is correct
42 Correct 86 ms 5240 KB Output is correct
43 Correct 87 ms 5240 KB Output is correct
44 Correct 120 ms 5248 KB Output is correct
45 Correct 160 ms 5368 KB Output is correct
46 Correct 184 ms 5368 KB Output is correct
47 Correct 75 ms 5240 KB Output is correct
48 Correct 90 ms 5240 KB Output is correct
49 Correct 108 ms 5324 KB Output is correct
50 Correct 127 ms 5248 KB Output is correct
51 Correct 72 ms 5240 KB Output is correct
52 Correct 92 ms 5240 KB Output is correct
53 Correct 111 ms 5248 KB Output is correct
54 Correct 136 ms 5248 KB Output is correct
55 Execution timed out 2093 ms 14068 KB Time limit exceeded
56 Halted 0 ms 0 KB -