Submission #157100

#TimeUsernameProblemLanguageResultExecution timeMemory
157100InfiniteJestGame (IOI14_game)C++14
15 / 100
2 ms504 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <math.h> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); typedef long long ll; int N; int k[1600]; int s[1600]; int p[1600][1600]; int find(int x){ while(x!=k[x])x=k[x]; return k[x]; } bool same(int a, int b){ return find(a)==find(b); } void unite(int a, int b){ a=find(a); b=find(b); if(s[a]<s[b])swap(a,b); k[b]=a; s[a]+=s[b]; for(int i=0;i<N;i++)p[a][i]+=p[b][i]; } void initialize(int n){ N=n; for(int i=0;i<n;i++){ k[i]=i; s[i]=1; } } int hasEdge(int u, int v){ u=find(u); v=find(v); if(u==v)return 1; if(p[u][v]+p[v][u]==s[u]*s[v]-1){ unite(u,v); return 1; } p[u][v]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...