Submission #103518

#TimeUsernameProblemLanguageResultExecution timeMemory
103518SecretAgent007Game (IOI14_game)C++17
42 / 100
1067 ms1656 KiB
//# include "game.h"
# include <bits/stdc++.h>

using namespace std;

vector< vector< int > > Graph;

vector< bool > visited;

int n_;

void cycle(int node){
    visited[node] =true;
    for(int i = 0; i < n_; i++){
        if(Graph[node][i] && !visited[i]){
            cycle(i);
        }
    }
}

void initialize(int n) {
    n_ = n;
    Graph.resize(n, vector<int>(n, false));

    visited.resize(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            Graph[i][j] = true;
            Graph[j][i] = true;
        }
    }
}

int hasEdge(int u, int v) {
    Graph[u][v] = false;
    Graph[v][u] = false;
    fill(visited.begin(), visited.end(), false);
    cycle(u);
    bool verif = true;
    for(int i = 0; i < n_; i++){
        if(!visited[i]) verif = false;
    }
    if(verif){
        return 0;
    }else{
        Graph[u][v] = true;
        Graph[v][u] = true;
        return 1;
    }
}
/*
signed main(){
    int n;

    cin >> n;
    initialize(n);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            cout << i << ' ' << j << ' ' << hasEdge(i,j) << endl;
        }
    }
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...