제출 #1296170

#제출 시각아이디문제언어결과실행 시간메모리
1296170avighnaCat in a tree (BOI17_catinatree)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, d; cin >> n >> d; vector<vector<int>> adj(n); for (int i = 1, p; i < n; ++i) { cin >> p; adj[p].push_back(i); cout << p << ' ' << i << '\n'; } if (d >= n) { cout << "1\n"; return 0; } auto dfs = [&](auto &&self, int u) -> deque<int> { deque<int> dp(n); for (int &i : adj[u]) { deque<int> ndp = self(self, i); ndp.push_front(0); ndp.pop_back(); deque<int> nndp(n); for (int i = 0; i < ndp.size(); ++i) { nndp[i] = max(dp[i], ndp[i]); } for (int i = 0; i < dp.size(); ++i) { for (int j = 0; j < ndp.size(); ++j) { if (i + j < d) { continue; } nndp[min(i, j)] = max(nndp[min(i, j)], dp[i] + ndp[j]); } } dp = nndp; } dp[0] = max(dp[0], dp[d] + 1); debug(u, dp); return dp; }; deque<int> dp = dfs(dfs, 0); cout << *max_element(dp.begin(), dp.end()) << '\n'; }

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

catinatree.cpp: In lambda function:
catinatree.cpp:44:5: error: there are no arguments to 'debug' that depend on a template parameter, so a declaration of 'debug' must be available [-fpermissive]
   44 |     debug(u, dp);
      |     ^~~~~
catinatree.cpp:44:5: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
catinatree.cpp: In instantiation of 'main()::<lambda(auto:54&&, int)> [with auto:54 = main()::<lambda(auto:54&&, int)>&]':
catinatree.cpp:48:22:   required from here
catinatree.cpp:44:10: error: 'debug' was not declared in this scope
   44 |     debug(u, dp);
      |     ~~~~~^~~~~~~