QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796565#7276. A Light InconvenienceomsincoconutCompile Error//C++141.2kb2024-12-01 21:15:502024-12-01 21:15:50

Judging History

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

  • [2024-12-01 21:15:50]
  • 评测
  • [2024-12-01 21:15:50]
  • 提交

answer

#include "light.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

vector<ll> cur;

void prepare() {
    cur = {1};
}

pair<ll, vector<ll>> join(ll p) {
    ll cz = cur.back() + p;

    vector<ll> newcur;
    newcur.push_back(1);

    for (ll i = 1; cz-i+1 > 1; i *= 2) newcur.push_back(cz-i+1);

    sort(newcur.begin(), newcur.end());
    newcur.resize(unique(newcur.begin(), newcur.end()) - newcur.begin());

    vector<ll> actual;

    ll t = 5*p;
    for (ll i : newcur) {
        ll gap = i - *(upper_bound(cur.begin(), cur.end(), i) - 1);
        if (gap <= t) actual.push_back(i);
    }

    cur = actual;

    return make_pair(t, cur);
}

pair<ll, vector<ll>> leave(ll p){
    ll cz = cur.back() - p;

    vector<ll> newcur;
    newcur.push_back(1);

    for (ll i = 1; cz-i+1 > 1; i *= 2) newcur.push_back(cz-i+1);

    sort(newcur.begin(), newcur.end());
    newcur.resize(unique(newcur.begin(), newcur.end()) - newcur.begin());

    vector<ll> actual;

    ll t = 5*p;
    for (ll i : newcur) {
        ll gap = i - *(upper_bound(cur.begin(), cur.end(), i) - 1);
        if (gap <= t) actual.push_back(i);
    }

    cur = actual;

    return make_pair(t, cur);
}

詳細信息

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)
      |                        ^