Submission #399587

#TimeUsernameProblemLanguageResultExecution timeMemory
399587JasiekstrzGame (IOI14_game)C++17
100 / 100
473 ms25288 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; const int N=15e2; int nn; int cnt[N+10][N+10]; int fau[N+10]; int f(int x) { if(fau[x]!=x) fau[x]=f(fau[x]); return fau[x]; } void un(int x,int y) { x=f(x); y=f(y); for(int i=0;i<nn;i++) cnt[x][i]=cnt[i][x]=cnt[x][i]+cnt[y][i]; fau[y]=x; return; } void initialize(int n) { nn=n; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) cnt[i][j]=1; fau[i]=i; } return; } int hasEdge(int u,int v) { u=f(u);v=f(v); //cerr<<u<<" "<<v<<"\n"; if(cnt[u][v]>1) { cnt[u][v]--; cnt[v][u]--; return 0; } un(u,v); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...