This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
typedef long long ll;
ll p[N];
ll edges[N][N];
int nodes;
ll find(ll u) {
return p[u] == u ? u : p[u] = find(p[u]);
}
void unite(ll u, ll v) {
u = find(u), v = find(v);
p[v] = u;
for (int i = 0; i <= nodes; i++) {
edges[u][i] = edges[v][i] + edges[u][i];
edges[i][u] = edges[i][v] + edges[i][u];
edges[v][i] = edges[i][v] = 0;
}
}
void initialize(int n) {
nodes = n;
for (int i = 0; i < 2e3 + 5; i++)
p[i] = i;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= n; j++)
edges[i][j] = 1;
}
int hasEdge(int u, int v) {
u = find(u), v = find(v);
edges[u][v]--, edges[v][u]--;
if (!edges[u][v]) {
unite(u, v);
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |