Submission #767548

# Submission time Handle Problem Language Result Execution time Memory
767548 2023-06-26T20:34:04 Z Essa2006 Synchronization (JOI13_synchronization) C++14
0 / 100
68 ms 12608 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int n, q1, q2, m;
vector<vector<int>>A;
map<int, pair<int, int>>mp;

void pre(){
    A.clear(), mp.clear();
    A.resize(n+1);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q1>>q2;
    pre();
    int cnt=1;
    while(m--){
        int u, v;
        cin>>u>>v;
        if(u>v)
            swap(u, v);
        A[u].push_back(v);
        A[v].push_back(u);
        mp[cnt++]={u, v};
    }
    vector<int>Mnr(n+1), Mxr(n+1), Mnf(n+1), Mxf(n+1);
    for(int i=1;i<=n;i++){
        Mnr[i]=Mxr[i]=Mnf[i]=Mxf[i]=i;
    }
    vector<bool>Active(n);
    while(q1--){
        int id;
        cin>>id;
        int u=mp[id].FF, v=mp[id].SS;
        if(!Active[id]){
            Mxf[u]=Mxf[v], Mnf[v]=Mnf[u];
            Mxr[u]=Mxr[v];
            Mnr[v]=Mnr[u];
        }
        else{
            Mxr[u]=u, Mnr[v]=v;
        }
        Active[id]=!Active[id];
    }
    while(q2--){
        int x;
        cin>>x;
        cout<<Mxf[x]-Mnf[x]+1<<endl;
    }
    
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 11728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 12608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -