이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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, false))
{
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... |