#include <bits/stdc++.h>
#include "game.h"
using namespace std;
#define N 1500
int S[N][N], R[N], T[N];
int n;
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
R[i] = i;
for (int j = i + 1; j < n; j++) {
S[i][j] = S[j][i] = 1;
}
}
}
int hasEdge(int u, int v) {
if (R[u] == R[v]) return 0;
if (S[R[u]][R[v]] > 1) {
S[R[u]][R[v]]--;
S[R[v]][R[u]]--;
return 0;
}
for (int i = 0; i < n; i++) T[i] = 0;
for (int i = 0; i < n; i++) {
if (R[i] != R[u] && R[i] != R[v] && !T[R[i]]) {
T[R[i]] = 1;
int k = S[R[u]][R[i]] + S[R[v]][R[i]];
S[R[u]][R[i]] = S[R[i]][R[u]] = k;
}
}
for (int i = 0; i < n; i++) {
if (R[i] == R[v]) R[i] = R[u];
}
return 1;
}
// int read_int() {
// int x;
// assert(scanf("%d", &x) == 1);
// return x;
// }
// int main() {
// int n, u, v;
// n = read_int();
// initialize(n);
// for (int i = 0; i < n * (n - 1) / 2; i++) {
// u = read_int();
// v = read_int();
// printf("%d\n", hasEdge(u, v));
// }
// 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... |