题目 › fcs-257

FrontierCS #257

FrontierCS 算法赛道 v1.1 · 2026-05 · L5 开放式 · C++17 · 时限 3 秒 · 0–100 连续分

查看原题跳到结果

题面

来源:FrontierCS 官方 statement.txt,与模型收到的题面相同。

Problem: Omkar and Modes Time limit: 3 seconds Memory limit: 256 MB This is an interactive problem. Ray lost his array and needs to find it by asking Omkar. Omkar is willing to disclose that the array has the following qualities: 1. The array has n (1 <= n <= 2 * 10^5) elements. 2. Every element in the array a_i is an integer in the range 1 <= a_i <= 10^9. 3. The array is sorted in nondecreasing order. Ray is allowed to send Omkar a series of queries. A query consists of two integers, l and r such that 1 <= l <= r <= n. Omkar will respond with two integers, x and f. - x is the mode of the subarray from index l to index r inclusive. The mode of an array is defined by the number that appears the most frequently. If there are multiple numbers that appear the most number of times, the smallest such number is considered to be the mode. - f is the amount of times that x appears in the queried subarray. The array has k (1 <= k <= min(25000, n)) distinct elements. However, due to Ray's sins, Omkar will not tell Ray what k is. Help Ray find his lost array. Input The only line of the input contains a single integer n (1 <= n <= 2 * 10^5), which equals to the length of the array that you are trying to find. Interaction Protocol The interaction starts with reading n. Then you can make one type of query: "? l r" (without quotes) (1 <= l <= r <= n) where l and r are the bounds of the subarray that you wish to query. The answer to each query will be in the form "x f" where x is the mode of the subarray and f is the number of times x appears in the subarray. x satisfies (1 <= x <= 10^9). f satisfies (1 <= f <= r - l + 1). If you make an invalid query (violating ranges), you will get an output "-1". If you terminate after receiving the response "-1", you will get the "Wrong answer" verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream. To output your answer, print: "! a_1 a_2 ... a_n" (without quotes) which is an exclamation point followed by the array with a space between every element. And quit after that. This query is not counted towards the query limit. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: - fflush(stdout) or cout.flush() in C++; - System.out.flush() in Java; - flush(output) in Pascal; - stdout.flush() in Python; - see documentation for other languages. Scoring The physical objective is per-case array query count Q_j; smaller is better. The physical reference is `a = k_j`; matching a positive reference earns 60 points. k_j is the number of distinct blocks in the hidden array; the implemented physical reference is max(1,k_j). Define the historical low-score expression (in points): P_low = 60*max(0,(12*k_j-Q_j)/(11*k_j))^2. A valid solution with `Q_j=0` receives 100 points, including a zero-baseline instance. Otherwise, if `P_low<=60`, retain `max(0,P_low)`. For `P_low>60` and a positive physical reference, award: r = a / Q_j P = min(100, 60 + ln(r)). Here `r` is the improvement factor relative to the physical reference, and `ln` is the natural logarithm with coefficient 1. In the uncapped upper branch, `r = exp(P-60)`: each additional point means an `exp(1)`-fold improvement in the physical objective. The factor is computed from the physical objective and its reference, not from a transformed reward or the old point score. Invalid output retains its existing rejection or zero score; the zero-cost exception applies only after validation. Apply this mapping to each internal case, then average the points. Both reported ratio channels use points divided by 100. Across official files, take the arithmetic mean. Example Input: 6 2 2 2 2 3 2 2 1 Example Output: ? 1 6 ? 1 3 ? 4 6 ? 3 4 ! 1 1 2 3 3 4

结果

Kimi K3.1 ProKimi

max

38.5

平均得分 ↑

  • 38.5采样 1 · 部分分
  • 42.9k平均输出 token(含思考) ↓
  • 30.2输出速度 tokens/s ↑
  • 1426 秒延迟 ↓

Kimi K3.1 Pro(high)Kimi high

high

46.3

平均得分 ↑

  • 46.3采样 1 · 部分分
  • 14.2k平均输出 token(含思考) ↓
  • 24.7输出速度 tokens/s ↑
  • 575 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

47.9

平均得分 ↑

  • 47.9采样 1 · 部分分
  • 80.9k平均输出 token(含思考) ↓
  • 158.2输出速度 tokens/s ↑
  • 512 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

23.0

平均得分 ↑

  • 23.0采样 1 · 部分分
  • 76.9k平均输出 token(含思考) ↓
  • 78.1输出速度 tokens/s ↑
  • 985 秒延迟 ↓

↑ 越大越好,↓ 越小越好。得分 0–100,按官方时限判定,所有测试点都满分才算解出。CPU 时间 / 官方解为解出的答案在官方解最慢的 3 个测试点上的 CPU 时间之比(几何平均),只比较官方解至少需要 0.05 秒的题;复杂度按增长幂次相对官方解分类。判题与计分见 原理。

代码

Kimi K3.1 Pro · 采样 1 · 138 行
#include <bits/stdc++.h>
using namespace std;

struct Solver {
    int n;
    vector<int> answer;
    vector<int> pointValue;

    explicit Solver(int n) : n(n), answer(n + 1, 0), pointValue(n + 1, 0) {}

    pair<int, int> ask(int l, int r) {
        cout << "? " << l << ' ' << r << endl;
        int x, f;
        if (!(cin >> x >> f)) exit(0);
        if (x == -1) exit(0);
        return {x, f};
    }

    int getPoint(int pos) {
        if (pointValue[pos] != 0) return pointValue[pos];
        int value = ask(pos, pos).first;
        pointValue[pos] = value;
        return value;
    }

    void fillInterval(int l, int r, int value) {
        fill(answer.begin() + l, answer.begin() + r + 1, value);
    }

    int locateRun(int l, int r, int x, int f) {
        if (getPoint(l) == x) return l;
        if (getPoint(r) == x) return r - f + 1;

        const int maxStart = r - f;
        const int minEnd = l + f;
        const int remaining = (r - l + 1) - f;

        auto ordinaryBinarySearch = [&]() {
            int lo = l + 1, hi = maxStart;
            while (lo < hi) {
                int mid = (lo + hi) >> 1;
                if (getPoint(mid) < x) lo = mid + 1;
                else hi = mid;
            }
            return lo;
        };

        int budget = 0;
        for (int t = remaining; t; t >>= 1) ++budget;

        int leftFalse = l;
        int rightFalse = r;
        long long leftStep = 1, rightStep = 1;
        int used = 0;

        while (true) {
            int p = (int)min<long long>(maxStart, (long long)l + leftStep);
            int value = getPoint(p);

            if (value >= x) {
                int lo = leftFalse + 1, hi = p;
                while (lo < hi) {
                    int mid = (lo + hi) >> 1;
                    if (getPoint(mid) < x) lo = mid + 1;
                    else hi = mid;
                }
                return lo;
            }

            leftFalse = p;
            leftStep <<= 1;
            if (++used >= budget) return ordinaryBinarySearch();

            int q = (int)max<long long>(minEnd, (long long)r - rightStep);
            value = getPoint(q);

            if (value <= x) {
                int lo = q, hi = rightFalse;
                while (hi - lo > 1) {
                    int mid = (lo + hi) >> 1;
                    if (getPoint(mid) <= x) lo = mid;
                    else hi = mid;
                }
                return lo - f + 1;
            }

            rightFalse = q;
            rightStep <<= 1;
            if (++used >= budget) return ordinaryBinarySearch();
        }
    }

    void solve(int l, int r) {
        if (l > r) return;

        if (l == r) {
            answer[l] = getPoint(l);
            return;
        }

        if (pointValue[l] != 0 && pointValue[l] == pointValue[r]) {
            fillInterval(l, r, pointValue[l]);
            return;
        }

        auto [x, f] = ask(l, r);
        if (f == r - l + 1) {
            fillInterval(l, r, x);
            return;
        }

        int start = locateRun(l, r, x, f);
        int finish = start + f - 1;
        fillInterval(start, finish, x);

        solve(l, start - 1);
        solve(finish + 1, r);
    }

    void run() {
        solve(1, n);
        cout << '!';
        for (int i = 1; i <= n; ++i) cout << ' ' << answer[i];
        cout << endl;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    if (!(cin >> n)) return 0;

    Solver solver(n);
    solver.run();
    return 0;
}