题面
来源: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; }
Kimi K3.1 Pro(high) · 采样 1 · 44 行
#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 k = 63 - __builtin_clzll(x); int n = 2 + 2 * k; vector<vector<int>> a(n + 1, vector<int>(n + 1, 0)); for (int j = 1; j <= n; ++j) a[1][j] = 1; a[2][2] = 1; int r = 2; for (int b = k - 1; b >= 0; --b) { if ((x >> b) & 1ULL) { for (int i = 1; i <= r - 1; ++i) { a[i][r + 1] = 1; } } a[r][r + 1] = 1; a[r + 1][r] = 1; a[r + 1][r + 1] = 1; a[r + 2][r + 1] = 1; a[r + 2][r + 2] = 1; r += 2; } cout << n << '\n'; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cout << a[i][j] << (j == n ? '\n' : ' '); } } return 0; }
DeepSeek Flash V4.1-1017 · 采样 1 · 64 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); unsigned long long x; cin >> x; vector<int> bits; while (x > 0) { bits.push_back(x & 1ULL); x >>= 1ULL; } reverse(bits.begin(), bits.end()); int G = (int)bits.size() - 1; int n = 3 + 2 * G; vector<vector<int>> grid(n + 1, vector<int>(n + 1, 0)); // Top wire for (int j = 1; j <= n; ++j) grid[1][j] = 1; int r0 = 3, c0 = 2; // Entry path to A0 for (int i = 1; i <= r0; ++i) grid[i][1] = 1; for (int j = 1; j <= c0; ++j) grid[r0][j] = 1; // Gadgets for remaining bits for (int idx = 1; idx < (int)bits.size(); ++idx) { int bit = bits[idx]; int t = idx - 1; int r = r0 + 2 * t; int c = c0 + 2 * t; grid[r + 1][c] = 1; grid[r][c + 1] = 1; grid[r + 1][c + 1] = 1; grid[r + 2][c + 1] = 1; grid[r + 2][c + 2] = 1; if (bit) { int C = c + 1; for (int row = 2; row <= r; ++row) { grid[row][C] = 1; } } } // Connect final A to (n,n) grid[n][n] = 1; cout << n << '\n'; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cout << grid[i][j] << (j == n ? '\n' : ' '); } } return 0; }
MiniMax M3.1 Flash · 采样 1 · 72 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); unsigned long long x; cin >> x; if (x == 1) { cout << "1\n1\n"; return 0; } int L = 64 - __builtin_clzll(x); int stages = L - 2; int n = 2 * stages + 4; vector<vector<int>> a(n, vector<int>(n, 0)); // The initial gadget has either 2 or 3 paths. int initial = int((x >> (L - 2)) & 3ULL); a[0][0] = 1; a[1][0] = 1; a[2][0] = a[2][1] = a[2][2] = 1; if (initial == 3) { a[2][3] = 1; } a[3][1] = a[3][2] = a[3][3] = 1; for (int stage = 0; stage < stages; ++stage) { int p = 3 + 2 * stage; // Boundary of a square: exactly two disjoint routes // from (p,p) to (p+2,p+2). for (int c = p; c <= p + 2; ++c) { a[p][c] = 1; a[p + 2][c] = 1; } for (int r = p; r <= p + 2; ++r) { a[r][p] = 1; a[r][p + 2] = 1; } int bitIndex = L - 3 - stage; int bit = int((x >> bitIndex) & 1ULL); if (bit == 1) { // A unique extra route from the upper rail into this stage. for (int r = 0; r <= p; ++r) { a[r][p + 2] = 1; } for (int c = 0; c <= p + 2; ++c) { a[0][c] = 1; } } } cout << n << '\n'; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (j) cout << ' '; cout << a[i][j]; } cout << '\n'; } return 0; }