题目 › fcs-222

FrontierCS #222

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

查看原题跳到结果

题面

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

Problem: Hedgehog Graph Time limit: 5 seconds Memory limit: 1024 megabytes This is an interactive problem. A hedgehog graph is a directed graph where each vertex has exactly one outgoing edge and contains exactly one directed cycle of length at least 3 (the graph does not contain a loop or cycle of length 2). For every edge e = u -> v in the hedgehog graph, v belongs to the aforementioned single directed cycle. For a vertex v, if there exists an edge v -> w we denote the vertex w = next(v) as the next vertex. This vertex exists and is unique. Kipa has n hedgehog graphs with 10^6 vertices. Each vertex is numbered from 1 to 10^6. Kipa is not given the graph directly. Instead, Kipa can ask queries to explore the graph. Your task is to help Kipa determine the length of the directed cycle for each hedgehog graph. Interaction Protocol First, your program must read from the standard input one line with the positive integer n, the number of graphs to process. n will be at most 10. For each graph, the program can ask the following query at most 2500 times: ? v x Given a vertex v and a positive integer x, the jury starts at v, moves to the next vertex x times, and returns the index of the resulting vertex. (1 <= v <= 10^6, 1 <= x <= 5 * 10^18) Once you have determined the length of the cycle s, output: ! s After that, read a single integer which is either: 1, if the answer is correct. You should immediately start processing the next graph, or finish your program with the exit code 0 if all n graphs are processed. -1, if the answer is incorrect. In this case, you should finish your program with exit code 0, in which case you will receive a Wrong Answer verdict. Failure to handle this properly may result in unexpected behavior. You must flush your output after every interaction. The interactor is adaptive. The interactor does not necessarily start with a fixed graph at the beginning of the interaction. It only guarantees that there exists at least one hedgehog graph that satisfies all the provided responses and the input specification. Example Input: 1 3 7 10 1 Example Output: ? 1 2 ? 2 5 ? 10 11 ! 11 Scoring The physical objective is per-graph query count Q_j; smaller is better. The physical reference is `a = 500`; matching a positive reference earns 60 points. Define the historical low-score expression (in points): P_low = 60*max(0,(2500-Q_j)/2000)^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.

结果

Kimi K3.1 ProKimi

max

9.3

平均得分 ↑

  • 9.3采样 1 · 部分分
  • 56.8k平均输出 token(含思考) ↓
  • 28.6输出速度 tokens/s ↑
  • 1988 秒延迟 ↓

Kimi K3.1 Pro(high)Kimi high

high

9.3

平均得分 ↑

  • 9.3采样 1 · 部分分
  • 3.8k平均输出 token(含思考) ↓
  • 23.5输出速度 tokens/s ↑
  • 165 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

9.3

平均得分 ↑

  • 9.3采样 1 · 部分分
  • 24.5k平均输出 token(含思考) ↓
  • 167.5输出速度 tokens/s ↑
  • 147 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

0.0

平均得分 ↑

  • 0.0采样 1 · 超时
  • 97.5k平均输出 token(含思考) ↓
  • 84.2输出速度 tokens/s ↑
  • 1159 秒延迟 ↓

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

代码

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

int ask(int v, long long x) {
    cout << "? " << v << " " << x << '\n' << flush;
    int response;
    cin >> response;
    return response;
}

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

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

    for (int tc = 0; tc < n; ++tc) {
        int start = ask(1, 1);

        vector<int> cache(1025, -1);
        cache[0] = start;

        auto getValue = [&](int x) -> int {
            if (cache[x] == -1) cache[x] = ask(start, x);
            return cache[x];
        };

        auto attempt = [&](int baby, int giants) -> int {
            unordered_map<int, int> position;
            position.reserve(2 * baby + 10);

            for (int i = 0; i < baby; ++i) {
                int w = getValue(i);
                auto it = position.find(w);
                if (it != position.end()) return i - it->second;
                position.emplace(w, i);
            }

            for (int k = 1; k <= giants; ++k) {
                int x = k * baby;
                int w = getValue(x);
                auto it = position.find(w);
                if (it != position.end()) return x - it->second;
            }
            return -1;
        };

        int answer = attempt(2, 4);
        if (answer == -1) answer = attempt(8, 4);
        if (answer == -1) answer = attempt(32, 32);

        if (answer == -1) {
            unordered_map<int, int> position;
            position.reserve(2048);

            for (int i = 0; i < 1000; ++i) {
                int w = getValue(i);
                auto it = position.find(w);
                if (it != position.end()) {
                    answer = i - it->second;
                    break;
                }
                position.emplace(w, i);
            }

            int k = 2;
            while (answer == -1) {
                int x = k * 1000;
                int w = ask(start, x);
                auto it = position.find(w);
                if (it != position.end()) answer = x - it->second;
                ++k;
            }
        }

        cout << "! " << answer << '\n' << flush;
        int verdict;
        if (!(cin >> verdict) || verdict == -1) return 0;
    }

    return 0;
}