답안 #709788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709788 2023-03-14T12:23:52 Z ngano_upat_na 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
#include "game.h"
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int N = 300000;
int K = -1;
bool done = false;
bool cyc = false;
vector<int> adj[N];
vector<bool> vis(N,false);

void dfs(int u) {
    if (vis[u]) {
        cyc = true;
        return;
    }
    vis[u] = true;
    for (auto &v:adj[u]) {
        dfs(v);
    }   
}   


void init(int n, int k) {
    N = n;
    K = k;
    for (int i=0; i<=k-2; i++) {
        adj[i].push_back(i+1);
    }   
}   

int add_teleporter(int u, int v) {
    adj[u].push_back(v);
    
    if (done) return 1;
    for (int i=0; i<N; i++) {
        vis[i] = false;
    }   
    cyc = false;
    dfs(0);
    
    if (cyc) return 1;
    return 0;
}   

Compilation message

game.cpp:10:18: error: array bound is not an integer constant before ']' token
   10 | vector<int> adj[N];
      |                  ^
game.cpp: In function 'void dfs(int)':
game.cpp:19:18: error: 'adj' was not declared in this scope
   19 |     for (auto &v:adj[u]) {
      |                  ^~~
game.cpp: In function 'void init(int, int)':
game.cpp:29:9: error: 'adj' was not declared in this scope
   29 |         adj[i].push_back(i+1);
      |         ^~~
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:34:5: error: 'adj' was not declared in this scope
   34 |     adj[u].push_back(v);
      |     ^~~