Submission #1289313

#TimeUsernameProblemLanguageResultExecution timeMemory
1289313tschav_Souvenirs (IOI25_souvenirs)C++20
Compilation error
0 ms0 KiB
#include "souvenirs.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

void buy_souvenirs(int N, ll P0) {
  vector<ll> P(N, 0ll);

  vector<int> freq(N,0ll);

  P[0] = P0;

  int L = N;

  auto rec = [&](ll coins, auto &&self) -> void {
    auto [R, ch] = transaction(coins);

    for(auto &i : R) {
      ++freq[i];
    }

    ll sum = coins - ch;

    // for(int j = R.size()-1; j >= 0; --j) {
    //   int idx = R[j];


    //   sum -= P[idx];  
    // }

for(int j = R.size()-1; j >= 0; --j) {
      int idx = R[j];

      if(idx < L) break;

      sum -= P[idx];
      R.pop_back();
    }

    while(R.size() - 1) {
      
      self((sum - ch) / R.size(), self);

      // cerr << sum << "->";

      for(int j = R.size()-1; j >= 0; --j) {
        int idx = R[j];

        // cerr << idx;

        if(idx < L) break;

        sum -= P[idx];
        R.pop_back();
      }
    }

    P[R.front()]= sum;

    if(L > R.front() + 1ll){
      solve(sum-1);
    }

    L = R.front();

    return;
  };

  for(int i = 1; i < N; ++i){
    while(freq[i] < i) {

      ++freq[i];
      transaction(P[i]);}
  }

  return;
}

Compilation message (stderr)

souvenirs.cpp: In lambda function:
souvenirs.cpp:62:7: error: there are no arguments to 'solve' that depend on a template parameter, so a declaration of 'solve' must be available [-fpermissive]
   62 |       solve(sum-1);
      |       ^~~~~
souvenirs.cpp:62:7: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)