# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062163 | andrei_iorgulescu | Game (IOI14_game) | C++14 | 242 ms | 26464 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 <bits/stdc++.h>
#include "game.h"
#warning That's not FB, that's my FB
using namespace std;
int n;
int sz[1505], t[1505];
int cnt[1505][1505];
void initialize(int N)
{
n = N;
for (int i = 1; i <= n; i++)
t[i] = i, sz[i] = 1;
}
int par(int x)
{
while (x != t[x])
x = t[x];
return x;
}
int hasEdge(int u, int v)
{
u++;
v++;
int ru = u, rv = v;
u = par(u), v = par(v);
if (u == v)
assert(false);
if (sz[u] < sz[v])
swap(u,v);
if (cnt[v][u] != sz[u] * sz[v] - 1)
{
cnt[v][u]++;
cnt[u][v]++;
return 0;
}
sz[u] += sz[v];
t[v] = u;
for (int x = 1; x <= n; x++)
{
if (t[x] == x and x != u and x != v)
{
cnt[x][u] += cnt[x][v];
cnt[u][x] += cnt[v][x];
}
}
return 1;
}
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... |