Submission #1269372

#TimeUsernameProblemLanguageResultExecution timeMemory
1269372rtriCop and Robber (BOI14_coprobber)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int n;
vector<vector<bool>> adj;

vector<bool> vis;
bool has_cycle(int u, int p = -1, int gp = -1) {
  // Special handle cycle of length 3
  if (u == gp)
    return false;

  if (vis[u])
    return true;
  vis[u] = true;

  for (int v = 0; v < n; v++)
    if (adj[u][v] && v != p)
      if (has_cycle(v, u, p))
        return true;
  return false;
}

vector<int> tin, tout, par;
int tick = 0;
void et(int u, int p = -1) {
  tin[u] = tick++;
  par[u] = p;
  for (int v = 0; v < n; v++)
    if (adj[u][v] && v != p)
      et(v, u);
  tout[u] = tick++;
}

bool subt(int u, int p) { return tin[p] <= tin[u] && tout[u] <= tout[p]; }

int cop = 0;
int start(int N, vector<vector<bool>> A) {
  n = N;
  adj = A;

  vis.resize(n);
  if (has_cycle(0))
    return -1;

  tin.resize(n);
  tout.resize(n);
  par.resize(n);
  et(0);

  return 0;
}

int nextMove(int R) {
  for (int v = 0; v < n; v++)
    if (adj[cop][v] && v != par[cop] && subt(R, v))
      return v;
  return par[cop];
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc1JfhH6.o: in function `main':
grader.cpp:(.text.startup+0x155): undefined reference to `start(int, bool (*) [500])'
collect2: error: ld returned 1 exit status