Submission #31721

#TimeUsernameProblemLanguageResultExecution timeMemory
31721top34051Game (IOI14_game)C++14
100 / 100
889 ms19664 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; #define maxn 1505 int n; int head[maxn]; int way[maxn][maxn]; int temp[maxn]; int findhead(int x) { if(head[x]==x) return x; return head[x] = findhead(head[x]); } void initialize(int N) { int i,j; n = N; for(i=0;i<n;i++) head[i] = i; for(i=0;i<n;i++) for(j=0;j<n;j++) way[i][j] = 1; } int hasEdge(int u, int v) { u = findhead(u); v = findhead(v); if(u==v) return 0; if(way[u][v]==1) { for(int i=0;i<n;i++) temp[i] = way[u][i] + way[v][i]; head[findhead(v)] = findhead(u); for(int i=0;i<n;i++) way[findhead(u)][i] = way[i][findhead(u)] = temp[i]; return 1; } else { way[u][v]--; way[v][u]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...