답안 #73273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73273 2018-08-28T06:27:45 Z nvmdava 친구 (IOI14_friend) C++17
컴파일 오류
0 ms 0 KB
#include "friend.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> p[1001];
int ans[1001][2];

inline void go(int v){
	for(auto x : p){
		go(x);
		ans[v][0] += max(ans[x][1], ans[x][0]);
		ans[v][1] += ans[x][0];
	}
}

int findSample(int n,int confidence[],int host[],int protocol[]){
	
	ans[0][1] = confidence[0];
	for(int i = 1; i < n; i++){
		p[host[i]].push_back(i);
		ans[i][1] = confidence[i];
	}
	go(i);
	return max(ans[i][0], ans[i][0]);
}

Compilation message

friend.cpp: In function 'void go(int)':
friend.cpp:10:7: error: cannot convert 'std::vector<int>' to 'int' for argument '1' to 'void go(int)'
   go(x);
       ^
friend.cpp:11:23: error: no match for 'operator[]' (operand types are 'int [1001][2]' and 'std::vector<int>')
   ans[v][0] += max(ans[x][1], ans[x][0]);
                       ^
friend.cpp:11:34: error: no match for 'operator[]' (operand types are 'int [1001][2]' and 'std::vector<int>')
   ans[v][0] += max(ans[x][1], ans[x][0]);
                                  ^
friend.cpp:12:19: error: no match for 'operator[]' (operand types are 'int [1001][2]' and 'std::vector<int>')
   ans[v][1] += ans[x][0];
                   ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:23:5: error: 'i' was not declared in this scope
  go(i);
     ^