Submission #835147

#TimeUsernameProblemLanguageResultExecution timeMemory
835147_martynas게임 (IOI14_game)C++11
42 / 100
1072 ms1212 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int mxn = 1505;

int n;
bool adj[mxn][mxn];

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

bool visited[mxn];
// check if it can be connected
void dfs_could(int u) {
    visited[u] = true;
    for(int v = 0; v < n; v++) if(!visited[v] && adj[u][v]) {
        dfs_could(v);
    }
}

int hasEdge(int u, int v) {
    bool add = false;
    adj[u][v] = adj[v][u] = false;
    fill(visited, visited+n, false);
    dfs_could(0);
    if(count(visited, visited+n, true) != n) {
        adj[u][v] = adj[v][u] = true;
        add = true;
    }
    return add;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...