Submission #105018

#TimeUsernameProblemLanguageResultExecution timeMemory
105018WLZ게임 (IOI14_game)C++14
0 / 100
3 ms404 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

vector< vector<int> > g;
vector<int> was;

void initialize(int n) {
  g.assign(n, vector<int>(n, 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        g[i][j] = 0;
      }
    }
  }
}

void dfs(int u) {
  was[u] = 1;
  for (int v = 1; v < (int) g[u].size(); v++) {
    if (g[u][v] && !was[v]) {
      dfs(v);
    }
  }
}

int hasEdge(int u, int v) {
  g[u][v] = g[v][u] = 0;
  was.assign((int) g.size(), 0);
  dfs(u);
  if (was[v]) {
    return 0;
  }
  g[u][v] = g[v][u] = 1;
  return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...