# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
835250 | Liudas | Game (IOI14_game) | C++17 | 284 ms | 15824 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 <iostream>
#include <numeric>
#include <vector>
#include <set>
using namespace std;
vector<vector<int>> matrix;
vector<int> par;
void initialize(int N){
par.resize(N);
matrix.assign(N, vector<int>(N, 1));
for(int i = 0; i < N; i ++){;
matrix[i][i] = 0;
}
iota(par.begin(), par.end(), 0);
}
int get(int x){
if(par[x] != x){
return par[x] = get(par[x]);
}
return x;
}
void merge(int a, int b){
par[a] = b;
}
int hasEdge(int u, int v){
u = get(u);
v = get(v);
matrix[u][v]--;
matrix[v][u]--;
if(matrix[u][v] == 0){
merge(u, v);
for(int i = 0; i < par.size(); i ++){
matrix[i][v] += matrix[i][u];
matrix[v][i] += matrix[u][i];
}
return 1;
}
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... |