# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332184 | zggf | Game (IOI14_game) | C++14 | 562 ms | 25452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> conv;
vector<vector<int>> tab;
void initialize(int n) {
conv.resize(n);
tab.resize(n, vector<int>(n, 1));
for(int i = 0; i < n; i++){
conv[i] = i;
}
}
int find(int x){
if(conv[x]==x) return x;
conv[x] = find(conv[x]);
return conv[x];
}
void merge(int a, int b){
conv[b] = a;
for(int i = 0; i < tab.size(); i++){
tab[a][i] += tab[b][i];
tab[i][a] += tab[i][b];
}
}
int hasEdge(int u, int v) {
u = find(u);
v = find(v);
if(tab[u][v]==1) {
merge(u, v);
return 1;
}
tab[u][v]--;
tab[v][u]--;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |