답안 #154708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154708 2019-09-23T18:25:41 Z dolphingarlic 친구 (IOI14_friend) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "friend.h"
using namespace std;

int colour[100001], dp[2][100001], c[100001];
vector<int> graph[100001];

void dfs(int node) {
    dp[0][node] = c[node];
    for (int i : graph[node]) {
        dfs(i);
        if (!colour[i])
            dp[1][node] += dp[0][i], dp[0][node] += dp[1][i];
        else if (colour[i] == 1)
            dp[0][node] += dp[0][i], dp[1][node] += dp[1][i];
        else
            dp[1][node] += dp[1][i];
    }
    int curr = dp[1][node];
    dp[0][node] = max(dp[0][node], curr);

    for (int i : graph[node]) {
        if (!colour[i])
            curr += dp[1][i] - dp[0][i];
        else 
            curr += dp[0][i] - dp[1][i];
        dp[0][node] = max(dp[0][node], curr);
        if (colour[i] == 2) curr += dp[1][i] - dp[0][i];
    }
}

int findSample(int n, int confidence[], int host[], int protocol[]) {
    c[0] = confidence[0];
    for (int i = 1; i < n; i++) {
        c[i] = confidence[i];
        colour[i] = protocol[i];
        graph[host[i]].push_back(i);
        if (protocol[i] == 2) yellow[host[i]].push_back(i);
    }
    dfs(0);
    return dp[0][0];
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:38:31: error: 'yellow' was not declared in this scope
         if (protocol[i] == 2) yellow[host[i]].push_back(i);
                               ^~~~~~
friend.cpp:38:31: note: suggested alternative: 'ftello'
         if (protocol[i] == 2) yellow[host[i]].push_back(i);
                               ^~~~~~
                               ftello