Submission #554369

#TimeUsernameProblemLanguageResultExecution timeMemory
554369Koosha_mvGame (IOI14_game)C++14
100 / 100
348 ms15852 KiB
#include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first #include "game.h" const int N=1505; int n,t,a[N],sz[N],col[N],g[N][N]; void initialize(int _n){ n=_n; f(i,1,n+1) col[i]=i,sz[i]=1; } int hasEdge(int u, int v){ u++,v++; if(g[col[u]][col[v]]+1==sz[col[u]]*sz[col[v]]){ f(i,1,n+1) g[col[u]][i]+=g[col[v]][i],g[i][col[u]]+=g[i][col[v]]; int cl=col[v]; f(i,1,n+1) if(col[i]==cl) col[i]=col[u],sz[col[u]]++; return 1; } g[col[u]][col[v]]++; g[col[v]][col[u]]++; return 0; } /* int32_t main(){ cin>>n; initialize(n); f(i,0,n*(n-1)/2){ int u,v; cin>>u>>v; cout<<hasEdge(u,v)<<endl; } }*/ /* 4 0 3 2 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...