Submission #1036955

#TimeUsernameProblemLanguageResultExecution timeMemory
1036955vaneaGame (IOI14_game)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
using ll = long long;

const int mxN = 2e3+10;

int cnt[mxN], n, past = 0;

int hasEdge(int u, int v) {
    ++cnt[u]; ++cnt[v];
    if(cnt[u] == n-1 || cnt[v] == n-1) --past;
    if(cnt[u] == n-1 || cnt[v] == n-1) return 1;
    if((cnt[u] == n-2 || cnt[v] == n-2) && past) {
        --past;
        if(cnt[u] == n-2) cnt[u] = n;
        else if(cnt[v] == n-2) cnt[v] = n;
        return 1;
    }
    if(cnt[u] == n-2) past++;
    if(cnt[v] == n-2) past++;
    return 0;
}

void initialize(int N) {
    n = N;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...