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<bits/stdc++.h>
#include "game.h"
using namespace std;
const int MAX_N = 1505;
int N;
int head[MAX_N], tail[MAX_N], nxt[MAX_N], Size[MAX_N];
int cnt[MAX_N][MAX_N];
void initialize(int n) {
N = n;
for(int i = 0; i < n; i++) {
head[i] = tail[i] = i;
nxt[i] = -1;
Size[i] = 1;
for(int j = 0; j < n; j++) {
cnt[i][j] = 1;
}
}
}
void Union(int u, int v) {
if(Size[u] > Size[v]) swap(u, v);
for(int i = tail[u]; i > -1; i = nxt[i]) {
head[i] = v;
}
nxt[u] = tail[v];
tail[v] = tail[u];
Size[v] += Size[u];
for(int i = 0; i < N; i++) {
cnt[i][v] = cnt[v][i] = cnt[i][u] + cnt[i][v];
}
}
int hasEdge(int u, int v) {
u = head[u], v = head[v];
if(cnt[u][v] == 1) {
Union(u, v);
return 1;
}
cnt[u][v]--;
cnt[v][u]--;
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... |