Submission #678606

#TimeUsernameProblemLanguageResultExecution timeMemory
678606penguin133Game (IOI14_game)C++17
100 / 100
335 ms25316 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; //#define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif int N; int par[1505]; int stuf[1505][1505], sz[1505]; int getr(int x){ return (par[x] == x ? x : par[x] = getr(par[x])); } void merge(int a, int b){ a = getr(a), b = getr(b); if(a == b)return; par[b] = a; sz[a] += sz[b]; for(int i=0;i<N;i++)stuf[a][i] += stuf[b][i], stuf[i][a] += stuf[i][b]; } void initialize(int n){ N = n; for(int i=0;i<n;i++)par[i] = i, sz[i] = 1; } int cnt = 0; int hasEdge(int u, int v){ int pu = getr(u), pv = getr(v); assert(pu != pv); stuf[pu][pv]++; stuf[pv][pu]++; //cerr << pu << " " << pv << " " << sz[pu] << " " << sz[pv] << " " << stuf[pu][pv] << '\n'; if(stuf[pu][pv] == sz[pu] * sz[pv]){ merge(pu, pv); return 1; } else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...