题目 › fcs-13

FrontierCS #13

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

查看原题跳到结果

题面

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

Time limit: 2 seconds Memory limit: 1024 megabytes This is an interactive problem. A mischievous robot is navigating an infinitely large 2D grid. However, its movement is confined to the first quadrant, meaning its coordinates (x, y) must always satisfy x > 0 and y > 0. Initially, the robot is located at grid coordinates (s_x, s_y). All grid cells are initially white. Set T = 3000. The game proceeds in discrete time steps. In each time step, the following sequence occurs: 1. Your Move: You choose integer coordinates (x_m, y_m) such that 1 <= x_m <= T and 1 <= y_m <= T. You then mark this cell black. A cell, once marked black, remains black for the rest of the game. You can mark any cell within the range, including the cell where the robot is currently located. 2. Robot’s Move: The robot, currently at position (r_x, r_y), observes the grid (including the cell you just marked black). It knows the locations of all currently black cells. It then moves to a new position (n_x, n_y). The new position (n_x, n_y) must be one of the 8 cells immediately adjacent (horizontally, vertically, or diagonally) to (r_x, r_y). That is, |n_x - r_x| <= 1 and |n_y - r_y| <= 1, and (n_x, n_y) ̸= (r_x, r_y). Additionally, the robot must stay within the first quadrant, so n_x > 0 and n_y > 0. The interactor (controlling the robot) will choose one valid move for the robot. The robot’s strategy is unknown to you. 3. Outcome Check: After the robot moves to (n_x, n_y), the system checks if the cell (n_x, n_y) is black. • If (n_x, n_y) is black, the robot explodes. • If (n_x, n_y) is white, the game continues to the next time step, with the robot now at (n_x, n_y). Your goal is to make the robot explode within as less steps as possiable. Answers exceeding 3000 steps are considered as incorrect answers. Input The first line of input contains two integers sx and sy (1 <= s_x, s_y <= 20), the initial coordinates of the robot. Interaction Protocol The interaction proceeds in turns for at most T turns. In each turn t (from t = 1 to T): 1. Your program must print one line containing two space-separated integers x_m and y_m, representing the coordinates of the cell you choose to mark black in this turn. Remember to flush the output stream. 2. The interactor reads your chosen coordinates (x_m, y_m). 3. The interactor determines the robot’s next move to (n_x, n_y) based on its current position and the set of all black cells (including the one just marked at (x_m, y_m) ). 4. The interactor checks if the cell (n_x, n_y) is black. • If it is black (robot explodes), the interactor will print a single line containing '0 0' and terminate. Your program should then read these values and terminate successfully. • If it is white, the interactor will print a single line containing two space-separated integers n_x and n_y, the new coordinates of the robot. Your program should read these coordinates to know the robot’s current position for the next turn. If the robot has not exploded after you have made T moves, your program should terminate. Your solution will be judged as incorrect in this case (or if you exceed the turn limit or make an invalid move). To flush your output, you can use fflush(stdout) (if you use printf) or cout.flush() (if you use cout). Example standard input 5 5 5 4 5 3 5 2 5 1 0 0 standard output 6 1 4 1 6 2 4 2 5 2 ## Scoring Let x be q, the number of turns used. R is the comparison turn count stored with the test, R<3000. The first turn is numbered 1. The physical reference (the 60-point level) is a=R. Define the lower-band continuation: L(x) = 60*max(0,(3000-x)/(3000-R)). 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). If a=0, the zero-cost rule still applies; positive x uses L(x). 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

49.0

平均得分 ↑

  • 49.0采样 1 · 部分分
  • 52.3k平均输出 token(含思考) ↓
  • 24.2输出速度 tokens/s ↑
  • 2167 秒延迟 ↓

Kimi K3.1 Pro(high)Kimi high

high

16.3

平均得分 ↑

  • 16.3采样 1 · 部分分
  • 30.7k平均输出 token(含思考) ↓
  • 22.8输出速度 tokens/s ↑
  • 1349 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

53.6

平均得分 ↑

  • 53.6采样 1 · 部分分
  • 103.8k平均输出 token(含思考) ↓
  • 181.0输出速度 tokens/s ↑
  • 574 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

0.0

平均得分 ↑

  • 0.0采样 1 · 答案错误
  • 65.2k平均输出 token(含思考) ↓
  • 95.4输出速度 tokens/s ↑
  • 684 秒延迟 ↓

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

代码

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

using P = pair<int, int>;

static const int T = 3000;
static const int N = 60;
static const int LOCAL_LIMIT = 180;
static const int EMERGENCY_LIMIT = 40;

set<P> blackCells;
vector<P> wallCells;
vector<P> fillCells;
int rx, ry, vx = 0, vy = 0;
int localUsed = 0, emergencyUsed = 0;

bool markable(P p) {
    return p.first >= 1 && p.first <= T && p.second >= 1 && p.second <= T;
}

bool isBlack(P p) {
    return blackCells.count(p);
}

vector<P> neighbors(P p) {
    vector<P> res;
    for (int dx = -1; dx <= 1; ++dx) {
        for (int dy = -1; dy <= 1; ++dy) {
            if (dx == 0 && dy == 0) continue;
            P q = {p.first + dx, p.second + dy};
            if (q.first > 0 && q.second > 0) res.push_back(q);
        }
    }
    return res;
}

int wallIndex(P p) {
    return p.first == N ? p.second : p.first;
}

bool baseWallCell(P p) {
    int i = wallIndex(p);
    return i % 3 != 0 || i <= 2 || i >= N - 2;
}

bool specialWallCell(P p) {
    int i = wallIndex(p);
    return i <= 2 || i >= N - 2;
}

bool adjacent(P a, P b) {
    return max(abs(a.first - b.first), abs(a.second - b.second)) <= 1;
}

vector<P> urgentWallCells(P p) {
    vector<P> res;
    for (P w : wallCells) {
        if (!isBlack(w) && adjacent(p, w)) res.push_back(w);
    }
    return res;
}

pair<int, int> deadlineInfo(P w, P p) {
    int best = 1000000;
    if (w.first == N) {
        int qx = N - 1;
        int lo = max(1, w.second - 1);
        int hi = min(N - 1, w.second + 1);
        for (int qy = lo; qy <= hi; ++qy) {
            best = min(best, max(abs(qx - p.first), abs(qy - p.second)));
        }
        return {best, abs(w.second - p.second)};
    } else {
        int qy = N - 1;
        int lo = max(1, w.first - 1);
        int hi = min(N - 1, w.first + 1);
        for (int qx = lo; qx <= hi; ++qx) {
            best = min(best, max(abs(qx - p.first), abs(qy - p.second)));
        }
        return {best, abs(w.first - p.first)};
    }
}

int dangerAfterMark(P candidate) {
    P p = {rx, ry};
    int danger = 0;
    for (P q : neighbors(p)) {
        if (q == candidate || isBlack(q)) continue;

        if (q.first >= N || q.second >= N) {
            danger += 1000;
            continue;
        }

        int whiteExits = 0;
        for (P w : wallCells) {
            if (w == candidate || isBlack(w)) continue;
            if (adjacent(q, w)) ++whiteExits;
        }
        if (whiteExits >= 2) danger += 10 * (whiteExits - 1);
    }
    return danger;
}

struct Plan {
    bool ok = false;
    int eta = 1000000;
    P target = {-1, -1};
    vector<P> offPath;
};

Plan makePlan(bool restrictToBox) {
    vector<P> dirs;
    if (vx != 0 || vy != 0) {
        dirs.push_back({vx, vy});
    } else {
        dirs = {
            {0, -1}, {-1, 0}, {1, -1}, {-1, -1},
            {1, 0}, {0, 1}, {1, 1}, {-1, 1}
        };
    }

    Plan best;
    int limit = restrictToBox ? N - 1 : T - 1;

    for (P d : dirs) {
        for (int k = 1; k <= 12; ++k) {
            P c = {rx + d.first * k, ry + d.second * k};
            if (c.first < 1 || c.second < 1 || c.first > limit || c.second > limit) continue;
            if (isBlack(c)) continue;

            bool bad = false;
            set<P> futurePath;
            for (int j = 1; j < k; ++j) {
                P q = {rx + d.first * j, ry + d.second * j};
                futurePath.insert(q);
                if (isBlack(q)) bad = true;
            }
            if (bad) continue;

            P previous = {c.first - d.first, c.second - d.second};
            vector<P> off;
            for (P q : neighbors(c)) {
                if (!markable(q) || q == previous || isBlack(q)) continue;
                if (futurePath.count(q)) {
                    bad = true;
                    break;
                }
                off.push_back(q);
            }
            if (bad) continue;
            if ((int)off.size() > k) continue;

            sort(off.begin(), off.end(), [](P a, P b) {
                if (a.second != b.second) return a.second < b.second;
                return a.first > b.first;
            });

            int eta = k + 1;
            if (eta < best.eta) {
                best.ok = true;
                best.eta = eta;
                best.target = c;
                best.offPath = off;
            }
        }
    }
    return best;
}

pair<P, bool> chooseWallMove() {
    vector<P> base, other;
    for (P w : wallCells) {
        if (isBlack(w)) continue;
        if (baseWallCell(w)) base.push_back(w);
        else other.push_back(w);
    }

    vector<P> candidates = !base.empty() ? base : other;
    if (candidates.empty()) return {{-1, -1}, false};

    int minimumDeadline = 1000000;
    for (P w : candidates) {
        minimumDeadline = min(minimumDeadline, deadlineInfo(w, {rx, ry}).first);
    }

    if (!base.empty() && minimumDeadline > 5) {
        vector<P> special;
        for (P w : candidates) {
            if (specialWallCell(w)) special.push_back(w);
        }
        if (!special.empty()) candidates = special;
    }

    P best = {-1, -1};
    int bestDanger = 1000000000;
    pair<int, int> bestInfo = {1000000000, 1000000000};

    for (P w : candidates) {
        int danger = dangerAfterMark(w);
        auto info = deadlineInfo(w, {rx, ry});
        if (best.first == -1 ||
            danger < bestDanger ||
            (danger == bestDanger && info < bestInfo)) {
            best = w;
            bestDanger = danger;
            bestInfo = info;
        }
    }

    if (bestDanger > 0 && emergencyUsed < EMERGENCY_LIMIT &&
        (rx >= N - 5 || ry >= N - 5)) {
        P emergency = {-1, -1};
        int emergencyDanger = bestDanger;
        for (P q : neighbors({rx, ry})) {
            if (q.first >= N || q.second >= N || !markable(q) || isBlack(q)) continue;
            int danger = dangerAfterMark(q);
            if (danger < emergencyDanger) {
                emergencyDanger = danger;
                emergency = q;
            }
        }
        if (emergency.first != -1) return {emergency, true};
    }

    return {best, false};
}

P chooseFillMove() {
    P best = {-1, -1};
    pair<int, pair<int, int>> bestScore = {1000000000, {1000000000, 1000000000}};

    for (P q : fillCells) {
        if (isBlack(q)) continue;
        int d = max(abs(q.first - rx), abs(q.second - ry));
        auto score = make_pair(d, make_pair(q.second, q.first));
        if (best.first == -1 || score < bestScore) {
            best = q;
            bestScore = score;
        }
    }
    return best;
}

P anyWhiteCell() {
    for (int x = 1; x <= 3000; ++x) {
        for (int y = 1; y <= 3000; ++y) {
            if (!isBlack({x, y})) return {x, y};
        }
    }
    return {1, 1};
}

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

    if (!(cin >> rx >> ry)) return 0;

    for (int y = 1; y <= N; ++y) wallCells.push_back({N, y});
    for (int x = 1; x < N; ++x) wallCells.push_back({x, N});

    for (int x = 1; x < N; ++x) {
        for (int y = 1; y < N; ++y) {
            if (!(x % 2 == 0 && y % 2 == 0)) fillCells.push_back({x, y});
        }
    }

    bool escaped = false;

    for (int turn = 1; turn <= T; ++turn) {
        bool wallSolid = true;
        for (P w : wallCells) {
            if (!isBlack(w)) {
                wallSolid = false;
                break;
            }
        }

        bool inside = rx > 0 && ry > 0 && rx < N && ry < N;
        if (!inside) escaped = true;

        vector<P> whiteMoves;
        bool unmarkableWhite = false;
        for (P q : neighbors({rx, ry})) {
            if (isBlack(q)) continue;
            if (!markable(q)) unmarkableWhite = true;
            whiteMoves.push_back(q);
        }

        P move = {-1, -1};
        bool emergencyMove = false;
        bool localMove = false;

        if (!unmarkableWhite && whiteMoves.size() <= 1) {
            if (whiteMoves.size() == 1) move = whiteMoves[0];
            else move = anyWhiteCell();
        }

        if (move.first == -1 && escaped) {
            Plan plan = makePlan(false);
            if (plan.ok && !plan.offPath.empty()) {
                move = plan.offPath.front();
            } else if (markable({rx, ry}) && !isBlack({rx, ry})) {
                move = {rx, ry};
            } else {
                for (P q : neighbors({rx, ry})) {
                    if (markable(q) && !isBlack(q)) {
                        move = q;
                        break;
                    }
                }
            }
        }

        if (move.first == -1 && !wallSolid) {
            vector<P> urgent = urgentWallCells({rx, ry});
            if (!urgent.empty()) {
                move = urgent[0];
                int bestDanger = dangerAfterMark(move);
                for (P w : urgent) {
                    int danger = dangerAfterMark(w);
                    if (danger < bestDanger ||
                        (danger == bestDanger && baseWallCell(w) && !baseWallCell(move))) {
                        move = w;
                        bestDanger = danger;
                    }
                }
            }
        }

        if (move.first == -1) {
            Plan plan = makePlan(true);
            bool canUse = plan.ok && !plan.offPath.empty() && localUsed < LOCAL_LIMIT;

            if (canUse && !wallSolid) {
                int distanceToWall = min(N - rx, N - ry);
                if (distanceToWall <= 20 && plan.eta > 4) canUse = false;
            }

            if (canUse) {
                move = plan.offPath.front();
                localMove = true;
            }
        }

        if (move.first == -1 && !wallSolid) {
            auto choice = chooseWallMove();
            move = choice.first;
            emergencyMove = choice.second;
        }

        if (move.first == -1 && wallSolid) {
            move = chooseFillMove();
        }

        if (move.first == -1 || !markable(move)) move = anyWhiteCell();

        if (localMove) ++localUsed;
        if (emergencyMove) ++emergencyUsed;

        cout << move.first << ' ' << move.second << endl;
        blackCells.insert(move);

        int nx, ny;
        if (!(cin >> nx >> ny)) return 0;
        if (nx == 0 && ny == 0) return 0;

        vx = nx - rx;
        vy = ny - ry;
        rx = nx;
        ry = ny;
    }

    return 0;
}