제출 #708156

#제출 시각아이디문제언어결과실행 시간메모리
708156CyanmondThe Big Prize (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include "prize.h"
#include <bits/stdc++.h>

std::map<int, std::vector<int>> askMemo;

std::vector<int> Ask(int i) {
    if (askMemo.find(i) != askMemo.end()) return askMemo[i];
    return askMemo[i] = ask(i);
}

std::vector<int> findLower(std::vector<int> ids) {
    auto question = [&](const int i) {
        return Ask(ids[i]);
    };

    const int n = (int)ids.size();
    const int limit = lm(n);
    std::vector<std::vector<int>> vals;
    for (int i = 0; i <= limit; ++i) {
        vals.push_back(question(i));
    }
    int df = 0;
    for (const auto &vec : vals) {
        df = std::max(df, vec[0] + vec[1]);
    }
    std::vector<int> lws;

    auto relax = [&](int i, std::vector<int> &ans) {
        for (const auto e : lws) {
            if (e < i) --ans[0];
            if (e > i) --ans[1];
        }
    };

    auto solve = [&](auto &&self, const int l, const int r, const int lv, const int rv) -> void {
        const int mid = (l + r) / 2;
        int lm = -1;
        for (int i = mid; i < r; ++i) {
            auto x = question(i);
            if (x[0] + x[1] != df) {
                lws.push_back(ids[i]);
            } else {
                lm = i;
                break;
            }
        }
        int rm = n + 1;
        for (int i = mid; i >= l; --i) {
            auto x = question(i);
            if (x[0] + x[1] != df) {
                lws.push_back(ids[i]);
            } else {
                rm = i;
                break;
            }
        }
        if (rm != n + 1) {
            auto x = question(rm);
            // relax(rm, x);
            const int newLv = lv, newRv = x[1];
            if (newLv + newRv != df) {
                self(self, l, rm, newLv, newRv);
            }
        }
        if (lm != -1) {
            auto x = question(lm);
            const int newLv = x[0], newRv = rv;
            if (newLv + newRv != df) {
                self(self, lm + 1, r, newLv, newRv);
            }
        }
    };
    solve(solve, 0, n, 0, 0);
    std::sort(lws.begin(), lws.end());
    return lws;
}

int find_best(int n) {
    std::vector<int> ids(n);
    std::iota(ids.begin(), ids.end(), 0);
    while (ids.size() != 1) {
        ids = findLower(ids);
    }
    return ids[0];
}

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'std::vector<int> findLower(std::vector<int>)':
prize.cpp:17:23: error: 'lm' was not declared in this scope; did you mean 'tm'?
   17 |     const int limit = lm(n);
      |                       ^~
      |                       tm