Submission #1181022

#TimeUsernameProblemLanguageResultExecution timeMemory
1181022kunzaZa183Game (IOI14_game)C++20
15 / 100
1 ms328 KiB
#include "game.h"

#include <bits/stdc++.h>
using namespace std;

int n;
int added = 0;
int remain;
vector<int> vi;

void initialize(int n) {
  ::n = n;
  remain = n * (n - 1) / 2;

  vi = vector<int>(n, n - 1);
}

int hasEdge(int u, int v) {
  remain--;
  if (vi[u] == 1 || vi[v] == 1) {
    added++;
    vi[u] = 0, vi[v] = 0;
    return 1;
  } else if (added + remain + 1 == n - 1) {
    added++;
    return 1;
  } else {
    vi[u]--, vi[v]--;
    return 0;
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...