# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722214 | 2023-04-11T15:13:24 Z | 600Mihnea | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include <cmath> #include <functional> #include <fstream> #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <map> #include <list> #include <time.h> #include <math.h> #include <random> #include <deque> #include <cassert> #include <queue> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <bitset> #include <sstream> #include <stack> #include <chrono> #include <cstring> #include <numeric> using namespace std; typedef long long ll; const int N = 200000 + 7; const ll INF = (ll)1e18 + 7; int n; int par[N]; int h[N]; int c[N]; vector<int> g[N]; int dep[N]; ll dp[N]; ll get(int a) { ll sol = c[a]; for (auto& b : g[a]) { sol += get(b); } sol = min(sol, dp[a]); return sol; } void compute(int a) { dp[a] = 0; for (auto& b : g[a]) { dp[a] += get(b); } } void build1(int a) { for (auto& b : g[a]) { dep[b] = 1 + dep[a]; build1(b); } } signed main() { #ifdef ONPC FILE* stream; freopen_s(&stream, "input.txt", "r", stdin); #else ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif cin >> n; for (int i = 1; i <= n; i++) { cin >> par[i] >> h[i] >> c[i]; dp[i] = INF; } assert(par[1] == 1); for (int i = 2; i <= n; i++) { assert(1 <= par[i] && par[i] <= i - 1); g[par[i]].push_back(i); } build1(1); vector<int> ord(n); iota(ord.begin(), ord.end(), 1); sort(ord.begin(), ord.end(), [&](int a, int b) { if (h[a] != h[b]) { return h[a] > h[b]; } return dep[a] > dep[b]; }); for (auto& a : ord) { compute(a); } cout << get(1, 0) << "\n"; return 0; }
Compilation message
worst_reporter2.cpp: In function 'int main()': worst_reporter2.cpp:87:18: error: no matching function for call to 'get(int, int)' 87 | cout << get(1, 0) << "\n"; | ^ worst_reporter2.cpp:37:4: note: candidate: 'll get(int)' 37 | ll get(int a) { | ^~~ worst_reporter2.cpp:37:4: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)' 223 | get(std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:223:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)' 228 | get(std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:228:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)' 233 | get(const std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:233:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)' 238 | get(const std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:238:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)' 247 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:247:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)' 252 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:252:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)' 257 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:257:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)' 262 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:262:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)' 267 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:267:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_Up, _Tp>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)' 272 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:272:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)' 277 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:277:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::pair<_Up, _Tp>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:38, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)' 282 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:282:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)' 334 | get(array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:334:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)' 343 | get(array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:343:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)' 351 | get(const array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:351:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)' 360 | get(const array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:360:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(std::tuple<_UTypes ...>&)' 1294 | get(tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1294:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(const std::tuple<_UTypes ...>&)' 1300 | get(const tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1300:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(std::tuple<_UTypes ...>&&)' 1306 | get(tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1306:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(const std::tuple<_UTypes ...>&&)' 1315 | get(const tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1344:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_UTypes ...>&)' 1350 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^ In file included from /usr/include/c++/10/functional:54, from worst_reporter2.cpp:2: /usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)' 1357 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1357:5: note: template argument deduction/substitution failed: worst_reporter2.cpp:87:18: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 87 | cout << get(1, 0) << "\n"; | ^