Submission #930639

#TimeUsernameProblemLanguageResultExecution timeMemory
930639imarnGame (IOI14_game)C++14
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define vvi vector<vi> #define vp vector<pii> using namespace std; const int N=1506; int sz[N]{0},del[N]{0},pr[N]{0},m; int get(int r){ return pr[r]==r?r:pr[r]=get(pr[r]); } void initialize(int n){ iota(pr,pr+n,0);m=n; for(int i=0;i<n;i++)sz[i]=1,del[i]=0; } int hasEdge(int u,int v){ int a=get(u),b=get(v); if(a==b)return 1; if(del[a]<sz[a]*(m-sz[a])&&del[b]<sz[b]*(m-sz[b])){del[a]++,del[b]++;return 0;} else {sz[a]+=sz[b],del[a]+=del[b],pr[b]=a;return 1;} }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...