Submission #678593

#TimeUsernameProblemLanguageResultExecution timeMemory
678593penguin133Game (IOI14_game)C++17
15 / 100
1 ms360 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]; } 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]++; if(sz[pu] * (sz[pu] - 1) / 2 + sz[pv] * (sz[pv] - 1) / 2 + stuf[pu][pv] == (sz[pu] + sz[pv]) * (sz[pu] + sz[pv] - 1) / 2){ 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...