Submission #874098

# Submission time Handle Problem Language Result Execution time Memory
874098 2023-11-16T09:12:18 Z itslq Friend (IOI14_friend) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> children[1005];
int dp(int w[], int id, bool t) {
    s = 0;
    if (t == 0) {
        for (int c: children[id]) {
            s += max(dp(w, c, 1), dp(w, c, 0));
        }
    } else {
        s += w[id];
        for (int c: children[id]) {
            s += dp(w, c, 0);
        }
    }
    return s;
}

int findSample(int n, int confidence[], int host[], int protocol[]) {
    if (protocol[1] == 0) {
        for (int i = 1; i < n; i++) children[host[i]].push_back(i);
        return max(dp(confidence, 0, 0), dp(confidence, 0, 1));
    } else if (protocol[1] == 2) {
        int m = -1;
        for (int i = 0; i < n; i++) m = max(m, confidence[i]);
        return m;
    }
}

Compilation message

friend.cpp: In function 'int dp(int*, int, bool)':
friend.cpp:6:5: error: 's' was not declared in this scope
    6 |     s = 0;
      |     ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^