제출 #446039

#제출 시각아이디문제언어결과실행 시간메모리
446039dxz05게임 (IOI14_game)C++14
42 / 100
1090 ms4548 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2048;

int n;
int H[MAXN][MAXN];

void initialize(int _n) {
    n = _n;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            H[i][j] = i != j;
        }
    }

}

bool used[MAXN];

void dfs(int v){
    used[v] = true;
    for (int u = 0; u < n; u++){
        if (!used[u] && H[v][u]) dfs(u);
    }
}

int hasEdge(int u, int v) {
    fill(used, used + n, false);
    H[u][v] = H[v][u] = 0;
    dfs(v);
    H[u][v] = H[v][u] = 1;

    if (used[u]){ /// NO
        H[u][v] = H[v][u] = 0;
        return 0;
    }

    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...