Submission #1102282

#TimeUsernameProblemLanguageResultExecution timeMemory
1102282ro9669Nile (IOI24_nile)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define fi first #define se second #define all(v) v.begin() , v.end() #define sz(v) int(v.size()) #define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin()); #include "nile.h" using namespace std; typedef long long ll; typedef pair<int , int> ii; typedef pair<long long , int> lli; const int maxN = int(2e5)+7; ll dp[maxN]; vector<long long> calculate_costs(vector<int> w , vector<int> a , vector<int> b , vector<int> e){ sort(all(id) , [](int x , int y){ return w[x] < w[y]; }); for (int d : e){ dp[0] = 0; for (int i = 0 ; i < sz(w) ; i++){ ll s = 0; int x = INT_MAX; dp[i + 1] = ll(1e18); for (int j = i ; j >= 0 ; j--){ s += b[id[j]]; x = min(x , a[id[j]] - b[id[j]]); if (w[id[i]] - w[id[j]] <= d){ if ((i - j)&1){ dp[i + 1] = min(dp[i + 1] , dp[j] + s); } else{ dp[i + 1] = min(dp[i + 1] , dp[j] + s + 1ll * x); } } else{ break; } } } res.push_back(dp[sz(w)]); } return res; }

Compilation message (stderr)

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:19:14: error: 'id' was not declared in this scope; did you mean 'ii'?
   19 |     sort(all(id) , [](int x , int y){
      |              ^~
nile.cpp:4:16: note: in definition of macro 'all'
    4 | #define all(v) v.begin() , v.end()
      |                ^
nile.cpp: In lambda function:
nile.cpp:20:16: error: 'w' is not captured
   20 |         return w[x] < w[y];
      |                ^
nile.cpp:19:21: note: the lambda has no capture-default
   19 |     sort(all(id) , [](int x , int y){
      |                     ^
nile.cpp:18:47: note: 'std::vector<int> w' declared here
   18 | vector<long long> calculate_costs(vector<int> w , vector<int> a , vector<int> b , vector<int> e){
      |                                   ~~~~~~~~~~~~^
nile.cpp:20:23: error: 'w' is not captured
   20 |         return w[x] < w[y];
      |                       ^
nile.cpp:19:21: note: the lambda has no capture-default
   19 |     sort(all(id) , [](int x , int y){
      |                     ^
nile.cpp:18:47: note: 'std::vector<int> w' declared here
   18 | vector<long long> calculate_costs(vector<int> w , vector<int> a , vector<int> b , vector<int> e){
      |                                   ~~~~~~~~~~~~^
nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:44:9: error: 'res' was not declared in this scope
   44 |         res.push_back(dp[sz(w)]);
      |         ^~~
nile.cpp:46:12: error: 'res' was not declared in this scope
   46 |     return res;
      |            ^~~