QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#380458#8573. Slothful Secretaryucup-team1134#WA 890ms40344kbC++231.8kb2024-04-07 04:15:462024-04-07 04:15:46

Judging History

This is the latest submission verdict.

  • [2024-04-07 04:15:46]
  • Judged
  • Verdict: WA
  • Time: 890ms
  • Memory: 40344kb
  • [2024-04-07 04:15:46]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,Q;cin>>N>>Q;
    vector<ll> deg(N),hin(N);
    set<int> SE;
    set<pair<int,int>> FL;
    for(int i=0;i<N;i++){
        deg[i]=i;
        hin[deg[i]]++;
        if(hin[deg[i]]==1) SE.insert(deg[i]);
    }
    
    while(Q--){
        int a,b;cin>>a>>b;a--;b--;
        if(FL.count(mp(a,b))){
            if(hin[deg[a]]==1) SE.erase(deg[a]);
            if(hin[deg[b]]==1) SE.erase(deg[b]);
            hin[deg[a]]--;
            hin[deg[b]]--;
            
            deg[a]--;
            deg[b]++;
            
            hin[deg[a]]++;
            hin[deg[b]]++;
            if(hin[deg[a]]==1) SE.insert(deg[a]);
            if(hin[deg[b]]==1) SE.insert(deg[b]);
            
            FL.erase(mp(a,b));
        }else{
            if(hin[deg[a]]==1) SE.erase(deg[a]);
            if(hin[deg[b]]==1) SE.erase(deg[b]);
            hin[deg[a]]--;
            hin[deg[b]]--;
            
            deg[a]++;
            deg[b]--;
            
            hin[deg[a]]++;
            hin[deg[b]]++;
            if(hin[deg[a]]==1) SE.insert(deg[a]);
            if(hin[deg[b]]==1) SE.insert(deg[b]);
            
            FL.insert(mp(a,b));
        }
        
        cout<<si(SE)<<"\n";
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 890ms
memory: 40344kb

input:

500000 500000
111236 111238
400537 400538
14798 14799
480138 480140
99901 99904
169041 169045
20969 20970
111098 111100
245492 245493
25296 25300
21736 21739
415491 415495
222594 222595
162236 162238
362422 362425
422694 422695
339973 339974
241678 241680
192401 192403
125627 125629
261473 261474
10...

output:

499998
499998
499998
499996
499994
499992
499992
499990
499990
499988
499986
499984
499984
499982
499980
499980
499980
499978
499976
499974
499974
499972
499972
499972
499972
499972
499972
499970
499968
499966
499964
499962
499962
499960
499958
499956
499954
499952
499950
499948
499946
499944
499942...

result:

wrong answer 5th numbers differ - expected: '499993', found: '499994'