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 <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 5000 + 10;
int n;
bool isPresent[MAXN][MAXN];
bool vis[MAXN];
bool dfs(int node, int v)
{
if (node == v || isPresent[node][v])
{
return true;
}
vis[node] = true;
for (int u = 1 ; u <= n ; ++u)
{
if (vis[u] || !isPresent[node][u])
{
continue;
}
if (dfs(u, v))
{
return true;
}
}
return false;
}
void initialize(int N)
{
n = N;
for (int i = 1 ; i <= n ; ++i)
{
std::fill(isPresent[i] + 1, isPresent[i] + 1 + n, true);
vis[i] = false;
}
}
int hasEdge(int u, int v)
{
u++; v++;
std::fill(vis + 1, vis + 1 + n, false);
isPresent[u][v] = 0;
isPresent[v][u] = 0;
if (dfs(u, v))
{
return 0;
}
isPresent[u][v] = 1;
isPresent[v][u] = 1;
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... |