Submission #502890

#TimeUsernameProblemLanguageResultExecution timeMemory
502890Urvuk3Game (IOI14_game)C++17
0 / 100
107 ms262148 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int MAXN=1505; #define ll long long #define MAXN 10000 #define fi first #define se second #define pll pair<ll,ll> #define pii pair<int,int> #define mid (l+r)/2 #define sz(a) int((a).size()) #define all(a) a.begin(),b.begin() #define mod 1000000007LL #define endl "\n" #define PRINT(x) cout<<#x<<'-'<<x<<endl ll n,res=0; int dsu[MAXN],sz[MAXN]; vector<vector<int>> cnt(MAXN,vector<int>(MAXN,1)); int root(int x){ while(x!=dsu[x]){ dsu[x]=dsu[dsu[x]]; x=dsu[x]; } return x; } void connect(int x,int y){ x=root(x); y=root(y); if(x!=y){ if(sz[x]<sz[y]){ swap(x,y); } dsu[y]=x; sz[x]+=sz[y]; } } void initialize(int n){ iota(dsu,dsu+MAXN,0); fill(sz,sz+MAXN,1); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i!=j){ cnt[i][j]=1; cnt[j][i]=1; } } } } int hasEdge(int u, int v){ int rtu=root(u),rtv=root(v); if(cnt[rtu][rtv]==1){ cnt[rtu][rtv]=0; cnt[rtv][rtu]=0; connect(u,v); for(int k=0;k<MAXN;k++){ int rtk=root(k); if(rtk==rtu || rtk==rtv) continue; cnt[rtu][rtk]+=cnt[rtv][rtk]; cnt[rtk][rtu]=cnt[rtu][rtk]; cnt[rtv][rtk]=cnt[rtu][rtk]; cnt[rtk][rtv]=cnt[rtu][rtk]; } return 1; } else{ int rtu=root(u),rtv=root(v); cnt[rtu][rtv]--; cnt[rtv][rtu]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...