题目 › fcs-58

FrontierCS #58

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

查看原题跳到结果

题面

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

Inverse Counting Path Walk Alone is an expert in dynamic programming, but he gets bored with traditional dynamic programming problem like counting paths on a 2-dimension grid, so he wants to do it in reverse. The problem he raised is as follows: On a 2-dimension grid of size n*n, originally you are on grid (1,1). The grid consists of 0 and 1, and you can only walk on the grid with number 1 in it. You can only go down or right, i.e. you can only increase your x or y by one. Also you cannot walk outside the grid. Given the number x of ways to walk from (1,1) to (n,n), you need to construct a grid of n*n so that the ways to walk is exactly x. However, since Walk Alone's brain is too small to memorize such a big grid, you need to guarantee that the size of the grid n is equal to or smaller than 300. Smaller grids improve the score as defined in Scoring. Input The only line of the input contains one integer x (1<=x<=10^18), denoting the ways to walk. Output The first line of the output contains the size of the grid n. Remind that you need to guarantee 1<=n<=300. The following n lines each contains n integers a_{i,j}∈{0,1} denoting the grid, where 0 denotes you cannot walk on the grid while 1 is on the contrast. Example Input 1: 3 Example Output 1: 3 1 1 0 1 1 0 1 1 1 Example Input 2: 10 Example Output 2: 4 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 ## Scoring Let x be n, the side length of the constructed grid. The objective is side length, not area. The physical reference (the 60-point level) is a=120. Define the lower-band continuation: L(x) = 100*max(0,min(1,1-x/300)). For positive x and positive physical reference a, define the improvement factor r=a/x. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are: P = 100, if x=0; P = L(x), if L(x)<=60; P = min(100,60+ln(r)), otherwise. Here ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (division by e). All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0. Across test files, use the arithmetic mean of the file scores.

结果

Kimi K3.1 ProKimi

max

60.1

平均得分 ↑

  • 60.1采样 1 · 部分分
  • 12.7k平均输出 token(含思考) ↓
  • 28.8输出速度 tokens/s ↑
  • 443 秒延迟 ↓

Kimi K3.1 Pro(high)Kimi high

high

33.1

平均得分 ↑

  • 33.1采样 1 · 部分分
  • 6.2k平均输出 token(含思考) ↓
  • 26.9输出速度 tokens/s ↑
  • 234 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

59.9

平均得分 ↑

  • 59.9采样 1 · 部分分
  • 61.1k平均输出 token(含思考) ↓
  • 182.4输出速度 tokens/s ↑
  • 335 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

60.1

平均得分 ↑

  • 60.1采样 1 · 部分分
  • 36.1k平均输出 token(含思考) ↓
  • 83.2输出速度 tokens/s ↑
  • 435 秒延迟 ↓

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

代码

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

int main() {
    unsigned long long x;
    cin >> x;

    if (x == 1) {
        cout << 1 << "\n1\n";
        return 0;
    }

    int L = 0;
    for (unsigned long long v = x; v; v >>= 1) ++L;

    int n = 2 * L - 1;
    vector<vector<int>> g(n, vector<int>(n, 0));

    auto open = [&](int r, int c) {
        g[r - 1][c - 1] = 1;
    };

    for (int c = 1; c <= n; ++c) open(1, c);

    open(2, 1);
    open(2, 2);
    open(3, 2);
    open(3, 3);

    if ((x >> (L - 2)) & 1ULL) open(3, 1);

    for (int t = 1; t <= L - 2; ++t) {
        open(2 * t + 2, 2 * t + 1);
        open(2 * t + 1, 2 * t + 2);
        open(2 * t + 2, 2 * t + 2);
        open(2 * t + 3, 2 * t + 2);
        open(2 * t + 3, 2 * t + 3);

        int bitIndex = L - 2 - t;
        if ((x >> bitIndex) & 1ULL) {
            for (int r = 2; r <= 2 * t; ++r) {
                open(r, 2 * t + 2);
            }
        }
    }

    cout << n << '\n';
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j) cout << ' ';
            cout << g[i][j];
        }
        cout << '\n';
    }

    return 0;
}