Submission #1083107

#TimeUsernameProblemLanguageResultExecution timeMemory
1083107n1k게임 (IOI14_game)C++17
42 / 100
1080 ms3740 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

int N;
int adj[1505][1505], seen[1505];

void dfs(int u){
    if(seen[u]) return;
    seen[u]=1;
    for(int v=0; v<N; v++)
        if(adj[u][v])
            dfs(v);
}

bool check(){
    bool ok = 1;
    for(int i=0; i<N; i++){
        seen[i]=0;
    }
    dfs(0);
    for(int i=0; i<N; i++){
        ok &= seen[i];
    }
    return ok;
}

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

int hasEdge(int u, int v) {
    adj[u][v] = adj[v][u] = 0;
    if(check()) return 0;
    else {
        adj[u][v] = adj[v][u] = 1;
        return 1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...