답안 #763652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763652 2023-06-22T15:04:05 Z vjudge1 Power Plant (JOI20_power) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int n;
vector<vector<int>> adjList;
vector<int> parent;
string isBased;

vector<int> dp;

int result = 0;

void depthFirstSearch(int u, int p)
{
    int V = 0;
    for (auto &v : adjList[u])
        if (v != p)
        {
            depthFirstSearchB(v, u);
            dp[u] += dp[v];
            if (dp[v] > dp[V])
                V = v;
        }

    if (isBased[u] == '1')
    {
        result = max(dp[V] + 1, result);
        dp[u] = max(1, dp[u] - 1);
    }

    result = max(dp[u], result);
}

int main()
{
    // freopen("inp.txt", "r", stdin);

    ios::sync_with_stdio(false);

    cin >> n;
    adjList.resize(n + 1);
    parent.resize(n + 1);
    for (int u, v, i = 1; i < n; i++)
    {
        cin >> u >> v;
        adjList[u].emplace_back(v);
        adjList[v].emplace_back(u);
    }
    cin >> isBased;
    isBased = "!" + isBased;

    dp.resize(n + 1);
    depthFirstSearch(1, -1);

    cout << result;
}

Compilation message

power.cpp: In function 'void depthFirstSearch(int, int)':
power.cpp:20:13: error: 'depthFirstSearchB' was not declared in this scope; did you mean 'depthFirstSearch'?
   20 |             depthFirstSearchB(v, u);
      |             ^~~~~~~~~~~~~~~~~
      |             depthFirstSearch