# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66847 | Kubalionzzale | Game (IOI14_game) | C++14 | 727 ms | 159164 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 "game.h"
#include <iostream>
#include <algorithm>
#include <set>
int cnt[1510] = { 0 };
int g[1510][1510] = { 0 };
//1 - not connected
//0 - connected
int n;
bool treed[1510] = { 0 };
void initialize(int N) {
n = N;
for (int i = 0; i < n; ++i)
{
cnt[i] = 1;
}
treed[0] = true;
}
int hasEdge(int u, int v) {
if (treed[u] && treed[v])
{
g[u][v] = 1;
g[v][u] = 1;
return 0;
}
if (!treed[u] && !treed[v])
{
g[u][v] = 1;
g[v][u] = 1;
return 0;
}
if (treed[u])
{
if (cnt[v] == 1)
{
for (int i = 0; i < n; ++i)
{
if (!g[i][v])
{
g[i][v] = 1;
++cnt[i];
}
}
treed[v] = true;
return 1;
}
else
{
g[u][v] = 1;
g[v][u] = 1;
--cnt[v];
return 0;
}
}
else if (treed[v])
{
if (cnt[u] == 1)
{
for (int i = 0; i < n; ++i)
{
if (!g[i][u])
{
g[i][u] = 1;
++cnt[i];
}
}
treed[u] = true;
return 1;
}
else
{
g[u][v] = 1;
g[v][u] = 1;
--cnt[u];
return 0;
}
}
}
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... |