Submission #841836

# Submission time Handle Problem Language Result Execution time Memory
841836 2023-09-02T07:19:00 Z manizare Cop and Robber (BOI14_coprobber) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h> 
#include "coprobber.h"

#define pb push_back 
#define F first 
#define S second 
#define all(a) a.begin(),a.end() 
#define pii pair<int,int>
#define int long long
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxk=1002 , sq = 333   , lg = 20 , K = 0,   inf = 1e18+10  , mod = 1e9 + 7 ;
int cnt = 0  , dis[500] , par[500] , st[500] , en[500] , cur = 0  ;
vector <int> G[500] ;
void dfs(int v , int p = -1){
  st[v] = cnt ; cnt++;
  for(int i =0 ; i < (int)G[v].size() ; i++){
    int u = G[v][i] ; 
    if(u== p)continue ;
    dis[u] = dis[v] + 1;
    dfs(u , v) ;
  }
  en[v] = cnt ; cnt ++ ;
}

int start(int N , bool a[500][500]){
  for(int i = 0 ; i < n ; i++){
    for(int j =0 ; j < n; j++){
      if(a[i][j])G[i].pb(j) ;
    }
  } 
  dfs(0) ;
  return 0; 
}

int ch(int v , int u){
  if(st[u] >= st[v] && en[v] >= en[u]){
     return 1; 
  }
  return 0 ;
}

int nextMove(int R){
  if(dis[R]-1 == dis[cur])return cur ; 
  for(int i =0 ; i < (int)G[cur].size() ; i++){
    int u = G[cur][i] ;
    if(ch(u, R) && ch(cur , u)){
      cur = u;
      break ;
    }
  }
  return cur ;
}

Compilation message

coprobber.cpp: In function 'long long int start(long long int, bool (*)[500])':
coprobber.cpp:28:23: error: 'n' was not declared in this scope
   28 |   for(int i = 0 ; i < n ; i++){
      |                       ^