답안 #744975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744975 2023-05-19T09:22:56 Z irmuun 경찰관과 강도 (BOI14_coprobber) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "coprobber.h"

using namespace std;
 
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

int n;
int start(int N,bool a[500][500]){
    n=N;
    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) continue;
            if(a[i][j]==true){
                adj[i].pb(j);
                cnt++;
            }
        }
    }
    if(cnt!=2*(n-1)){
        return -1;
    }
    return 0;
}
vector<int>used(500),p(500);
int cur=0,f=0;
void dfs(int u){
    used[u]=1;
    for(auto v:adj[u]){
        if(used[v]==0){
            p[v]=u;
            dfs(v);
        }
    }
}
int nextmove(int r){
    if(f==0){
        dfs(0);
        f=1;
    }
    if(p[r]==cur){
        return cur;
    }
    while(p[r]!=cur){
        r=p[r];
    }
    return r;
}

Compilation message

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:20:17: error: 'adj' was not declared in this scope
   20 |                 adj[i].pb(j);
      |                 ^~~
coprobber.cpp: In function 'void dfs(int)':
coprobber.cpp:34:16: error: 'adj' was not declared in this scope
   34 |     for(auto v:adj[u]){
      |                ^~~