题面
来源:FrontierCS 官方 statement.txt,与模型收到的题面相同。
Maze
Time limit: 2s
Memory limit: 512MB
3.1 Background
The subject of this work is SCP-167. It is recommended to review information about SCP-167 before proceeding with the work.
3.2 Description
SCP-167 can be roughly described as a point connected to an infinitely deep binary tree, as shown in the figure below.
Level 0 o
|
Level 1 o
/
Level 2 o ...
/
Level 3 o ...
o
o
o
We define the point at Level 0 as the exit of SCP-167. To prevent researchers from getting lost inside SCP-167, you need to write a pathfinding system to help SCP-167 researchers find the exit.
For a researcher lost in SCP-167, because the three edges connected to their current node are highly similar, they cannot tell which edge leads towards the exit.
In SCP-167, one becomes lost as soon as they cannot determine the absolute position of their current node. At this point, all you know is the relative path between points.
To easily describe relative paths, we can assume each edge is one of three colors: red, yellow, or blue, and the three edges connected to any single node are all different colors.
Thus, each move can be represented by a color, indicating the edge of that color.
Simultaneously, you have a ranging device that can measure the distance between your current node and the exit.
Assume you are lost in SCP-167. You only know the initial distance initialDeep between your current node and the exit, but not the absolute position of this node. Please write a pathfinding system to locate the exit.
3.3 Task Description
To simulate being lost, we have prepared an interaction library. You will read initialDeep from the standard input, which represents the distance between your initial position and the exit. Here, initialDeep ≤ 10^4. You can perform the following two operations by outputing to the interactor by standard output. After each operation, you need to flush the output and read the returned value of the interactor from the standard input.
"move c"
where c is an integer 0, 1, or 2, which represent red, yellow and blue respectively. You can perform such operation for at most
10^5
times. Once you have reached the exit, you must not move again. The interactor will return 1 if you reach the exit after the move. Otherwise, it will return 0.
"query"
The interactor will return the distance between your current node and the exit. You may make at most 100000 distance queries; exceeding this limit receives zero points. This limit is separate from the limit of 100000 moves. The number of times you make a query will determine your score. Details are shown below.
## Scoring
All feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.
Q is the number of distance queries. Define the objective x=Q, its physical reference a=A=5000, and the lower-band calculation L=60*5001/(Q+1).
```text
P = 100, if x = 0
P = L, if L <= 60 and x > 0
P = min(100, 60 + ln(r)), otherwise
```
Zero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. The +1 shift is used only in L, not in the logarithm. The checker reports P/100.
结果
Kimi K3.1 ProKimi
max
0.0
平均得分 ↑
- 0.0采样 1 · 编译错误
- 39.3k平均输出 token(含思考) ↓
- 27.7输出速度 tokens/s ↑
- 1422 秒延迟 ↓
Kimi K3.1 Pro(high)Kimi high
high
59.8
平均得分 ↑
- 59.8采样 1 · 部分分
- 10.7k平均输出 token(含思考) ↓
- 24.1输出速度 tokens/s ↑
- 445 秒延迟 ↓
DeepSeek Flash V4.1-1017DeepSeek
auto(high)
59.8
平均得分 ↑
- 59.8采样 1 · 部分分
- 71.3k平均输出 token(含思考) ↓
- 175.3输出速度 tokens/s ↑
- 408 秒延迟 ↓
MiniMax M3.1 FlashMiniMax
auto(max)
59.6
平均得分 ↑
- 59.6采样 1 · 部分分
- 81.7k平均输出 token(含思考) ↓
- 84.2输出速度 tokens/s ↑
- 971 秒延迟 ↓
↑ 越大越好,↓ 越小越好。得分 0–100,按官方时限判定,所有测试点都满分才算解出。CPU 时间 / 官方解为解出的答案在官方解最慢的 3 个测试点上的 CPU 时间之比(几何平均),只比较官方解至少需要 0.05 秒的题;复杂度按增长幂次相对官方解分类。判题与计分见 原理。
代码
Kimi K3.1 Pro · 采样 1 · 32 行
#include <bits/stdc++.h> using namespace std; static mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count()); static int movesUsed = 0; bool makeMove(int c) { cout << "move " << c << '\n' << flush; int result; cin >> result; ++movesUsed; return result == 1; } int makeQuery() { cout << "query\n" << flush; int distance; cin >> distance; return distance; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int depth; if (!(cin >> initialDeep)) { return 0; } return 0; }
Kimi K3.1 Pro(high) · 采样 1 · 121 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); const int MOVE_LIMIT = 100000; int initialDeep; cin >> initialDeep; if (initialDeep == 0) return 0; mt19937 rng( static_cast<unsigned int>( chrono::high_resolution_clock::now().time_since_epoch().count() ) ^ random_device{}() ); int movesUsed = 0; auto doMove = [&](int c) -> int { cout << "move " << c << '\n' << flush; ++movesUsed; int result; cin >> result; return result; }; auto doQuery = [&]() -> int { cout << "query\n" << flush; int result; cin >> result; return result; }; int depth = initialDeep; int incoming = -1; // Find the first upward edge. Afterwards, the color of the edge // leading back down is known, so only two colors need consideration. for (int c = 0; c < 3; ++c) { if (doMove(c)) return 0; if (c == 2) { depth = initialDeep - 1; incoming = c; break; } int newDepth = doQuery(); if (newDepth == initialDeep - 1) { depth = newDepth; incoming = c; break; } doMove(c); // Return to the initial node. } while (depth > 0) { int t = min(8, depth); // Reserve enough moves to finish deterministically, using at most // three moves per remaining level. while (t > 1 && movesUsed + 3 * t + 3 * (depth - 1) > MOVE_LIMIT) { --t; } vector<int> path; path.reserve(t); int previous = incoming; for (int i = 0; i < t; ++i) { int c = static_cast<int>(rng() % 2); if (c >= previous) ++c; path.push_back(c); previous = c; } bool reachedExit = false; for (int c : path) { if (doMove(c)) { reachedExit = true; break; } } if (reachedExit) return 0; int newDepth = doQuery(); int k = (depth + t - newDepth) / 2; if (k == t) { // Every move was upward. depth -= t; incoming = path.back(); continue; } // The first k moves were upward, move k+1 was downward, and all // subsequent moves were also downward. int incomingAtFailure = (k == 0 ? incoming : path[k - 1]); int forcedUp = 3 - incomingAtFailure - path[k]; for (int i = t - 1; i >= 0; --i) { if (doMove(path[i])) return 0; } for (int i = 0; i < k; ++i) { if (doMove(path[i])) return 0; } if (doMove(forcedUp)) return 0; depth -= k + 1; incoming = forcedUp; } return 0; }
DeepSeek Flash V4.1-1017 · 采样 1 · 133 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h; cin >> h; if (h == 0) { return 0; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long moves_used = 0; long long queries_used = 0; int came_from; int c = rng() % 3; cout << "move " << c << endl; int resp; cin >> resp; moves_used++; if (resp == 1) { return 0; } cout << "query" << endl; int d; cin >> d; queries_used++; if (d == h - 1) { h = d; came_from = c; } else { cout << "move " << c << endl; cin >> resp; moves_used++; if (resp == 1) { return 0; } came_from = c; } while (h > 0) { long long M_rem = 100000 - moves_used; long long R = M_rem - 3LL * (h - 1); long long max_L_safe = (R - 1) / 2; if (max_L_safe < 1) max_L_safe = 1; int L_exp = 1; int max_cand = min(h, 60); for (int Lcand = 1; Lcand <= max_cand; ++Lcand) { double p; if (Lcand == 1) p = 1.0; else { if (Lcand - 1 >= 60) p = 2.0; else p = 2.0 - 1.0 / (double)(1LL << (Lcand - 1)); } double cost = (2.0 * Lcand) / p; if (cost * h <= (double)M_rem + 1e-9) { L_exp = Lcand; } else { break; } } int L = min({L_exp, (int)max_L_safe, h, 60}); if (L < 1) L = 1; vector<int> path; path.reserve(L); int prev = came_from; bool exited = false; for (int i = 0; i < L; ++i) { int cand[2]; int idx = 0; for (int col = 0; col < 3; ++col) { if (col != prev) { cand[idx++] = col; } } int chosen = cand[rng() % 2]; path.push_back(chosen); cout << "move " << chosen << endl; cin >> resp; moves_used++; if (resp == 1) { exited = true; break; } prev = chosen; } if (exited) { return 0; } cout << "query" << endl; int d_final; cin >> d_final; queries_used++; int m = (h + L - d_final) / 2; if (m == L) { h = h - L; came_from = path.back(); } else { for (int i = L - 1; i >= m; --i) { int col = path[i]; cout << "move " << col << endl; cin >> resp; moves_used++; if (resp == 1) { return 0; } } int prev_color = (m > 0) ? path[m - 1] : came_from; int wrong_color = path[m]; int correct_color = 3 - prev_color - wrong_color; cout << "move " << correct_color << endl; cin >> resp; moves_used++; if (resp == 1) { return 0; } h = h - m - 1; came_from = correct_color; } } return 0; }
MiniMax M3.1 Flash · 采样 1 · 340 行
#include <bits/stdc++.h> using namespace std; static constexpr int MOVE_LIMIT = 100000; int movesUsed = 0; int queriesUsed = 0; uint64_t seed = chrono::steady_clock::now().time_since_epoch().count(); mt19937 rng(static_cast<uint32_t>(seed ^ (seed >> 32))); void performMove(int color) { cout << "move " << color << '\n' << flush; int response; if (!(cin >> response)) exit(0); ++movesUsed; if (response == 1) exit(0); } int performQuery() { cout << "query\n" << flush; int distance; if (!(cin >> distance)) exit(0); ++queriesUsed; return distance; } vector<int> childColors(int parentColor) { vector<int> colors; for (int color = 0; color < 3; ++color) { if (color != parentColor) colors.push_back(color); } return colors; } void exhaustiveSearch(int level, int parentColor, int targetDepth) { vector<int> colors = childColors(parentColor); for (int color : colors) { performMove(color); if (level + 1 == targetDepth) { performMove(color); } else { exhaustiveSearch(level + 1, color, targetDepth); performMove(color); } } } int partialLimit = 0; bool partialStopped = false; bool partialSearch(int level, int parentColor, int targetDepth) { if (level == targetDepth) return true; vector<int> colors = childColors(parentColor); shuffle(colors.begin(), colors.end(), rng); bool complete = true; for (int color : colors) { if (partialStopped) { complete = false; break; } performMove(color); bool childComplete = partialSearch(level + 1, color, targetDepth); performMove(color); if (!childComplete) complete = false; if (movesUsed >= partialLimit) { partialStopped = true; break; } } return complete && !partialStopped; } void partialSearchFromRoot(int targetDepth, array<bool, 3>& knownChild) { vector<int> firstColors{0, 1, 2}; shuffle(firstColors.begin(), firstColors.end(), rng); partialLimit = 98000; partialStopped = false; for (int color : firstColors) { if (partialStopped) break; performMove(color); bool complete = partialSearch(1, color, targetDepth); performMove(color); if (complete) knownChild[color] = true; if (movesUsed >= partialLimit) partialStopped = true; } } class Solver { public: int depth; array<bool, 3> knownChild{false, false, false}; explicit Solver(int initialDepth) : depth(initialDepth) {} int knownCount() const { return static_cast<int>(knownChild[0]) + static_cast<int>(knownChild[1]) + static_cast<int>(knownChild[2]); } int onlyUnknownParentColor() const { int sum = 0; int count = 0; for (int color = 0; color < 3; ++color) { if (knownChild[color]) { sum += color; ++count; } } if (count == 1) return 3 - sum; for (int color = 0; color < 3; ++color) { if (!knownChild[color]) return color; } return -1; } void resetKnownChild(int color = -1) { knownChild.fill(false); if (color >= 0) knownChild[color] = true; } void finishAtDepthOne() { while (depth > 0) { vector<int> candidates; for (int color = 0; color < 3; ++color) { if (!knownChild[color]) candidates.push_back(color); } for (int color : candidates) { performMove(color); performMove(color); } } } void directAscend() { while (depth > 0) { int count = knownCount(); if (count == 2) { int parentColor = onlyUnknownParentColor(); performMove(parentColor); --depth; resetKnownChild(parentColor); continue; } vector<int> candidates; for (int color = 0; color < 3; ++color) { if (!knownChild[color]) candidates.push_back(color); } shuffle(candidates.begin(), candidates.end(), rng); int color = candidates.front(); performMove(color); int queriedDepth = performQuery(); if (queriedDepth == depth - 1) { --depth; resetKnownChild(color); } else { performMove(color); if (count == 0) { resetKnownChild(color); } else { int oldChildColor = 0; for (int c = 0; c < 3; ++c) { if (knownChild[c]) oldChildColor = c; } int parentColor = 3 - oldChildColor - color; performMove(parentColor); --depth; resetKnownChild(parentColor); } } } } bool canRunProbe(int length) const { int minimumGain = (knownCount() >= 1 ? 1 : 0); int remainingDepth = depth - minimumGain; long long worstProbeMoves = 2LL * length + 1; long long directFallbackMoves = 3LL * remainingDepth + 2; return movesUsed + worstProbeMoves + directFallbackMoves <= MOVE_LIMIT; } void probe(int length) { int oldKnownCount = knownCount(); int oldKnownColor = -1; for (int color = 0; color < 3; ++color) { if (knownChild[color]) oldKnownColor = color; } vector<int> candidates; for (int color = 0; color < 3; ++color) { if (!knownChild[color]) candidates.push_back(color); } shuffle(candidates.begin(), candidates.end(), rng); vector<int> path; path.reserve(length); int previousColor = candidates.front(); path.push_back(previousColor); performMove(previousColor); for (int i = 1; i < length; ++i) { vector<int> choices; for (int color = 0; color < 3; ++color) { if (color != previousColor) choices.push_back(color); } int color = choices[rng() & 1U]; path.push_back(color); performMove(color); previousColor = color; } int queriedDepth = performQuery(); int numerator = depth + length - queriedDepth; if (numerator < 0 || (numerator & 1)) exit(0); int upwardSteps = numerator / 2; if (upwardSteps == 0) { for (int i = length - 1; i >= 0; --i) { performMove(path[i]); } if (oldKnownCount == 1) { int parentColor = 3 - oldKnownColor - path[0]; performMove(parentColor); --depth; resetKnownChild(parentColor); } else { resetKnownChild(path[0]); } } else if (upwardSteps == length) { depth -= length; resetKnownChild(path.back()); } else { for (int i = length - 1; i >= upwardSteps; --i) { performMove(path[i]); } int parentColor = 3 - path[upwardSteps - 1] - path[upwardSteps]; performMove(parentColor); depth -= upwardSteps + 1; resetKnownChild(parentColor); } } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int initialDepth; if (!(cin >> initialDepth)) return 0; if (initialDepth == 0) return 0; if (initialDepth <= 14) { exhaustiveSearch(0, -1, initialDepth); return 0; } array<bool, 3> knownChild{false, false, false}; if (15 <= initialDepth && initialDepth <= 20) { partialSearchFromRoot(initialDepth, knownChild); } Solver solver(initialDepth); solver.knownChild = knownChild; while (solver.depth > 0) { if (solver.depth == 1) { solver.finishAtDepthOne(); break; } if (solver.depth <= 14) { long long requiredMoves = 6LL * ((1LL << solver.depth) - 1); if (movesUsed + requiredMoves <= MOVE_LIMIT) { exhaustiveSearch(0, -1, solver.depth); return 0; } } int selectedLength = 0; int maximumLength = min(10, solver.depth); for (int length = maximumLength; length >= 1; --length) { if (solver.canRunProbe(length)) { selectedLength = length; break; } } if (selectedLength == 0) { solver.directAscend(); } else { solver.probe(selectedLength); } } return 0; }