QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#546663#7276. A Light Inconveniencehztmax0Compile Error//C++14637b2024-09-04 11:19:032024-09-04 11:19:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-04 11:19:03]
  • 评测
  • [2024-09-04 11:19:03]
  • 提交

answer

#include <algorithm>
#include <vector>
#include "light.h"

using namespace std;
using LL = long long;

LL N = 1;
vector<LL> act = {1};

void prepare () {}

pair<LL, vector<LL>> solve (LL p) {
  vector<LL> ret = {N};
  LL x = N;
  while (x > 1) {
    x -= min(x - 1, N - x + 2);
    int i = upper_bound(act.begin(), act.end(), x) - act.begin() - 1;
    if (x - act[i] > p)
      x = act[i + 1];
    ret.insert(ret.begin(), x);
  }
  swap(ret, act);
  return {p, act};
}

pair<LL, vector<LL>> join (LL p) {
  N += p;
  return solve(p);
}

pair<LL, vector<LL>> leave (LL p) {
  N -= p;
  return solve(p);
}

Details

implementer.cpp:17:22: error: ‘optional’ does not name a type
   17 | template<typename T> optional<T> read() {
      |                      ^~~~~~~~
implementer.cpp: In function ‘int main()’:
implementer.cpp:36:17: error: ‘optional’ was not declared in this scope
   36 |                 optional<long long> d = read<long long>();
      |                 ^~~~~~~~
implementer.cpp:36:17: note: ‘std::optional’ is only available from C++17 onwards
implementer.cpp:36:26: error: expected primary-expression before ‘long’
   36 |                 optional<long long> d = read<long long>();
      |                          ^~~~
implementer.cpp:37:24: error: ‘d’ was not declared in this scope
   37 |                 if(not d or *d == 0)
      |                        ^