제출 #586327

#제출 시각아이디문제언어결과실행 시간메모리
586327SeDunion친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
#include "friend.h"
#include<iostream>
#include<assert.h>

using namespace std;

const int N = 1e6 + 123;

vector<int>g[N];
int c[N];

int used[N];

void dfs(int v, int &a, int &b) {
	a += c[a];
	used[v] = 1;
	for (int to : g[v]) if (!used[to]) {
		dfs(to, b, a);
	}
}

int findSample(int n,int confidence[],int host[],int protocol[]){
	for (int i = 1 ; i < n ; ++ i) {
		assert(host[i] < i);
	}
	for (int i = 0 ; i < n ; ++ i) {
		c[i] = confidence[i];
	}
	for (int i = 1 ; i < n ; ++ i) {
		int j = host[i];
		g[j].emplace_back(i);
		g[i].emplace_back(j);
	}
	int a = 0, b = 0;
	dfs(0, a, b);
	return max(a, b);
}

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp:9:1: error: 'vector' does not name a type
    9 | vector<int>g[N];
      | ^~~~~~
friend.cpp: In function 'void dfs(int, int&, int&)':
friend.cpp:17:16: error: 'g' was not declared in this scope
   17 |  for (int to : g[v]) if (!used[to]) {
      |                ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:31:3: error: 'g' was not declared in this scope
   31 |   g[j].emplace_back(i);
      |   ^