题目 › fcs-111

FrontierCS #111

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

查看原题跳到结果

题面

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

Problem: Distinct Pairwise XOR Set Time Limit: 1 second Memory Limit: 512 MB Description Given an integer n, find a subset S ⊆ {1, 2, ..., n} such that: 1) For all pairs (a, b) with a, b ∈ S and a < b, the values (a XOR b) are all distinct (i.e., no two different unordered pairs produce the same XOR). 2) |S| ≥ floor(sqrt(n / 2)). Input A single integer n (1 ≤ n ≤ 10^7). Output - First line: an integer m — the size of the set S. - Second line: m distinct integers in the range [1, n] — the elements of S, in any order. Notes - Any valid S is accepted. You do NOT need to maximize m; you only need m ≥ floor(sqrt(n/2)). - The pairwise XOR distinctness means the set {a_i XOR a_j | 1 ≤ i < j ≤ m} has size m*(m-1)/2. - Multiple correct outputs may exist for the same n. - Print out the sequence with the longest length. Sample Input 49 Output 4 1 2 3 4 ## 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 maximizing quantity or quality and a for its physical 60-point reference. The improvement factor is r=x/a, 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. X is the submitted valid XOR-set size and R>0 is the size of the validated reference set. Define the objective x=X, its physical reference a=A=R, and the lower-band calculation L=60*X/R. ```text P = L, if L <= 60 P = min(100, 60 + ln(r)), otherwise ``` Zero value of a maximizing objective is not a perfect solution and earns no special full-score award. The checker reports P/100.

结果

Kimi K3.1 ProKimi

max

60.0

平均得分 ↑

  • 60.0采样 1 · 部分分
  • 36.0k平均输出 token(含思考) ↓
  • 28.9输出速度 tokens/s ↑
  • 1246 秒延迟 ↓

Kimi K3.1 Pro(high)Kimi high

high

60.0

平均得分 ↑

  • 60.0采样 1 · 部分分
  • 13.3k平均输出 token(含思考) ↓
  • 26.5输出速度 tokens/s ↑
  • 507 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

60.0

平均得分 ↑

  • 60.0采样 1 · 部分分
  • 71.3k平均输出 token(含思考) ↓
  • 174.7输出速度 tokens/s ↑
  • 408 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

60.0

平均得分 ↑

  • 60.0采样 1 · 部分分
  • 89.4k平均输出 token(含思考) ↓
  • 80.0输出速度 tokens/s ↑
  • 1118 秒延迟 ↓

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

代码

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

static inline int gf_mul(int a, int b, int k, int poly) {
    int res = 0;
    const int top = 1 << k;
    while (b) {
        if (b & 1) res ^= a;
        b >>= 1;
        a <<= 1;
        if (a & top) a ^= poly;
    }
    return res & (top - 1);
}

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

    int n;
    cin >> n;

    const int poly[13] = {
        0, 0x3, 0x7, 0xB, 0x13, 0x25, 0x43,
        0x83, 0x11D, 0x211, 0x409, 0x805, 0x1053
    };

    int bestCount = 1;
    int bestK = -1, bestType = 0, bestC = 0;

    for (int k = 1; k <= 12; ++k) {
        const int q = 1 << k;
        vector<int> cube(q);

        for (int x = 0; x < q; ++x) {
            int sq = gf_mul(x, x, k, poly[k]);
            cube[x] = gf_mul(sq, x, k, poly[k]);
        }

        for (int c = 0; c < q; ++c) {
            int cnt0 = 0, cnt1 = 0;

            for (int x = 0; x < q; ++x) {
                int f = cube[x] ^ c;
                int v0 = (x << k) | f;
                int v1 = (f << k) | x;

                if (v0 >= 1 && v0 <= n) ++cnt0;
                if (v1 >= 1 && v1 <= n) ++cnt1;
            }

            if (cnt0 > bestCount) {
                bestCount = cnt0;
                bestK = k;
                bestType = 0;
                bestC = c;
            }
            if (cnt1 > bestCount) {
                bestCount = cnt1;
                bestK = k;
                bestType = 1;
                bestC = c;
            }
        }
    }

    vector<int> answer;
    if (bestK == -1) {
        answer.push_back(1);
    } else {
        const int k = bestK;
        const int q = 1 << k;
        vector<int> cube(q);

        for (int x = 0; x < q; ++x) {
            int sq = gf_mul(x, x, k, poly[k]);
            cube[x] = gf_mul(sq, x, k, poly[k]);
        }

        for (int x = 0; x < q; ++x) {
            int f = cube[x] ^ bestC;
            int v = (bestType == 0)
                  ? ((x << k) | f)
                  : ((f << k) | x);
            if (v >= 1 && v <= n) answer.push_back(v);
        }
    }

    cout << answer.size() << '\n';
    for (size_t i = 0; i < answer.size(); ++i) {
        if (i) cout << ' ';
        cout << answer[i];
    }
    cout << '\n';

    return 0;
}