Submission #1166969

#TimeUsernameProblemLanguageResultExecution timeMemory
1166969HappyCapybara게임 (IOI14_game)C++17
42 / 100
1094 ms11980 KiB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;

int n;
vector<unordered_set<int>> h;

bool check(){
    vector<bool> seen(n, false);
    int x = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()){
        int cur = q.front();
        q.pop();
        if (seen[cur]) continue;
        seen[cur] = true;
        x++;
        for (int next : h[cur]) q.push(next);
    }
    return (x == n);
}

void initialize(int n){
    ::n = n;
    h.resize(n);
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if (i != j) h[i].insert(j);
        }
    }
}

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