Submission #782259

#TimeUsernameProblemLanguageResultExecution timeMemory
782259AndreyGame (IOI14_game)C++14
100 / 100
287 ms15768 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int br[1501][1501]; vector<int> dsu(1501); int k; int calc(int a) { int c = a,d; while(dsu[a] != a) { a = dsu[a]; } while(c != dsu[c]) { d = dsu[c]; dsu[c] = a; c = d; } return a; } void initialize(int n) { k = n; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { br[i][j] = 1; } } for(int i = 0; i < n; i++) { dsu[i] = i; } } int hasEdge(int u, int v) { int a = calc(u),b = calc(v); if(br[a][b] == 1) { br[a][b] = 0; br[b][a] = 0; dsu[b] = a; for(int i = 0; i < k; i++) { br[a][i] = br[a][i]+br[b][i]; br[i][a] = br[a][i]; } return 1; } else { br[a][b]--; br[b][a]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...