Submission #1068529

# Submission time Handle Problem Language Result Execution time Memory
1068529 2024-08-21T10:28:53 Z erray From Hacks to Snitches (BOI21_watchmen) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#include "books.h"

using namespace std;

#ifdef DEBUG 
  #include "/home/ioi/contests/boi21_d1/debug.h"
#else 
  #define debug(...) void(37)
#endif

void solve(int N, int K, long long A, int S) {
  vector<int64_t> mem(N + 1, -1);
  mem[N] = 2 * A + 1;
  auto Ask = [&](int i) {
    if (mem[i] != -1) {
      return mem[i];
    }
    mem[i] = skim(i + 1);
    return mem[i];
  };
  
  int low = 0, high = N;
  while (low < high) {
    int mid = (low + high) >> 1;
    if (Ask(mid) <= A) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  int big = low;
  if (big < K - 1) {
    impossible();
    return;
  }
  int64_t sum = 0;
  for (int i = 0; i < K - 1; ++i) {
    sum += Ask(i);
  }
  sum += Ask(big); 
  if (sum > 2 * A) {
    if (big == K - 1) {
      impossible();
      return;
    }
    sum += Ask(big - 1) - Ask(big);
    --big;
  }
  
  if (sum < A) {
    int p = 0;
    while (p < K - 1) {
      sum += Ask(big - 1 - p) - Ask(K - 2 - p);
      if (A <= sum) {
        vector<int> res(K);
        iota(res.begin(), res.end(), 1);
        for (int i = 0; i <= p + 1; ++i) {
          res[K - 1 - i] = big + 1 - i;
        }
        answer(res);
        return;
      }
      ++p;
    }
  } else if (sum > 2 * A) {
   sum += Ask(K - 1) -  Ask(big);
   if (sum < 2 * A) {
     vector<int> res(K);
     iota(res.begin(), res.end(), 1);
     answer(res);
     return;
   }
  } else {
    vector<int> res(K);
    iota(res.begin(), res.end(), 1);
    res[K - 1] = big + 1;
    answer(res);
    return;
  }
  impossible();
}

Compilation message

watchmen.cpp:3:10: fatal error: books.h: No such file or directory
    3 | #include "books.h"
      |          ^~~~~~~~~
compilation terminated.