This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#ifndef _GAME_H
#define _GAME_H
void initialize(int n);
int hasEdge(int u, int v);
#include <cstdio>
#include <cassert>
#include "game.h"
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;
}
#endif
#else
#include "game.h"
#endif
#include <bits/stdc++.h>
const int mxN = 1500;
int s[mxN][mxN];
int n;
std::vector<int> r[mxN];
int f[mxN];
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
r[i].push_back(i);
f[i] = i;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) s[i][j] = 1;
}
}
}
#ifdef LOCAL
#include "template\debug.hpp"
#else
#define dbg(...) ;
#define timer(...) ;
#endif
int hasEdge(int u, int v) {
int a = f[u], b = f[v];
dbg(a, b);
// let's delete this
s[a][b]--;
s[b][a]--;
if (s[a][b] >= 1) {
return 0;
}
// we move em
// move from one to another
for (int i : r[b]) {
r[a].push_back(i);
f[i] = a;
}
for (int i = 0; i < n; i++) {
if (i != a) {
s[a][i] += s[b][i];
s[i][a] += s[b][i];
}
s[b][i] = s[i][b] = 0;
}
dbg(std::vector<int>(f, f + n));
for (int i = 0; i < n; i++) {
dbg(std::vector<int>(s[i], s[i] + n));
}
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |