제출 #773794

#제출 시각아이디문제언어결과실행 시간메모리
773794boris_mihov게임 (IOI14_game)C++17
42 / 100
1069 ms4396 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...