Submission #867445

#TimeUsernameProblemLanguageResultExecution timeMemory
867445sleepntsheepBiochips (IZhO12_biochips)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); #define N 200050 using ll = long long; int n, m, a[N], timer, dp[2][N]; vector<int> g[N]; vector<tuple<int, int, int>> v; void dfs(int u) { int in = timer++; for (auto v : g[u]) dfs(v); int out = timer++; v.emplace_back(out, in, a[u]); } void schedule() { for (int j = 1; j <= m; ++j) { for (auto i = 1; i <= n; ++i) { int l = 0, r = i-1; auto it = partition_point(ALL(v), [&](auto it){ return get<0>(*it) < get<1>(v[i]); }); dp[j&1][i] = max(dp[j&1][i-1], dp[!(j&1)][it-v.begin()] + get<2>(v[i])); } } } int main() { ShinLena; cin >> n >> m; for (int p, i = 1; i <= n; ++i) cin >> p >> a[i], g[p].push_back(i); v={{-1e9,0,0}};dfs(0); sort(ALL(v)); schedule(); cout << dp[m&1][n]; return 0; }

Compilation message (stderr)

biochips.cpp: In function 'void schedule()':
biochips.cpp:33:17: warning: unused variable 'l' [-Wunused-variable]
   33 |             int l = 0, r = i-1;
      |                 ^
biochips.cpp:33:24: warning: unused variable 'r' [-Wunused-variable]
   33 |             int l = 0, r = i-1;
      |                        ^
biochips.cpp: In instantiation of 'schedule()::<lambda(auto:1)> [with auto:1 = std::tuple<int, int, int>]':
/usr/include/c++/10/bits/stl_algo.h:573:14:   required from '_FIter std::partition_point(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<std::tuple<int, int, int>*, std::vector<std::tuple<int, int, int> > >; _Predicate = schedule()::<lambda(auto:1)>]'
biochips.cpp:34:97:   required from here
biochips.cpp:34:75: error: no match for 'operator*' (operand type is 'std::tuple<int, int, int>')
   34 |             auto it = partition_point(ALL(v), [&](auto it){ return get<0>(*it) < get<1>(v[i]); });
      |                                                                           ^~~