답안 #706538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706538 2023-03-07T01:47:57 Z grossly_overconfident 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adjchart;
int K, N;
bool cycledetector4000(int i, int oi, bool f, vector<bool>& v, vector<bool>& dpcache){
	if (!f && i == oi){
		return true;
	}
	if (v[i]){
		return dpcache[i];
	}
	bool pl = false;
	for (int j : adjchart[i]){
		pl |= cycledetector4000(j, oi, false, v, dpcache);
	}
	v[i] = true;
	return dpcache[i] = pl;
}

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

int add_teleporter(int u, int v) {
	adjchart[u].push_back(v);
	vector<bool> v(N);
	vector<bool> dpcache(N);
	bool pl = false;
    for (int i = 0; i < K; ++i){
		pl |= cycledetector4000(i, i, true, v, dpcache);
	}
	if (pl){
		return 1;
	}
	return 0;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:32:15: error: declaration of 'std::vector<bool> v' shadows a parameter
   32 |  vector<bool> v(N);
      |               ^
game.cpp:30:31: note: 'int v' previously declared here
   30 | int add_teleporter(int u, int v) {
      |                           ~~~~^