Submission #1062951

#TimeUsernameProblemLanguageResultExecution timeMemory
1062951YassirSalamaGame (IOI14_game)C++17
100 / 100
252 ms15904 KiB
// #include "game.h" #include<bits/stdc++.h> using namespace std; const int maxn=1501; int par[maxn]; int cnt[maxn][maxn]; int n; void initialize(int _n) { n=_n; for(int i=0;i<n;i++) par[i]=i; for(int i=0;i<n;i++) for(int j=0;j<n;j++) cnt[i][j]=1; } int find(int node){ return node==par[node]?node:par[node]=find(par[node]); } void merge(int a,int b){ a=find(a);b=find(b); if(a==b) return; for(int i=0;i<n;i++) cnt[a][i]+=cnt[b][i],cnt[i][a]+=cnt[i][b]; par[b]=a; } int hasEdge(int u, int v) { u=find(u); v=find(v); // cout<<cnt[u][v]<<endl; if(cnt[u][v]==1){ merge(u,v);return 1; } cnt[u][v]--,cnt[v][u]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...