Submission #313926

# Submission time Handle Problem Language Result Execution time Memory
313926 2020-10-17T10:24:19 Z vipghn2003 Joker (BOI20_joker) C++14
0 / 100
4 ms 4992 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)
{
    int x=Find(u);
    int y=Find(v);
    if(x==y&&a[u]==a[v]) 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(a[u]==a[v]) 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 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -