题面
来源:EGOI 2026 官方 PDF。模型收到的是由同一份 Typst 源文件转换的文字。



结果
Kimi K3.1 ProKimi
auto(max)
3/3
解出的采样 ↑
- 100采样 1 · 解出
- 100采样 2 · 解出
- 100采样 3 · 解出
- 10.0k平均输出 token(含思考) ↓
- 29.3输出速度 tokens/s ↑
- 344 秒延迟 ↓
DeepSeek Flash V4.1-1017DeepSeek
auto(high)
3/3
解出的采样 ↑
- 100采样 1 · 解出
- 100采样 2 · 解出
- 100采样 3 · 解出
- 12.3k平均输出 token(含思考) ↓
- 210.0输出速度 tokens/s ↑
- 62 秒延迟 ↓
MiniMax M3.1 FlashMiniMax
auto(max)
3/3
解出的采样 ↑
- 100采样 1 · 解出
- 100采样 2 · 解出
- 100采样 3 · 解出
- 16.2k平均输出 token(含思考) ↓
- 136.0输出速度 tokens/s ↑
- 130 秒延迟 ↓
↑ 越大越好,↓ 越小越好。得分 0–100,按官方时限判定,所有测试点都满分才算解出。CPU 时间 / 官方解为解出的答案在官方解最慢的 3 个测试点上的 CPU 时间之比(几何平均),只比较官方解至少需要 0.05 秒的题;复杂度按增长幂次相对官方解分类。判题与计分见 原理。
代码
Kimi K3.1 Pro · 采样 1 · 85 行
#include <bits/stdc++.h> using namespace std; constexpr int MAX_W = 50; struct Node { unsigned char nxt[MAX_W + 1]; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> w(N); long long totalWeight = 0; for (int &x : w) { cin >> x; totalWeight += x; } int size = 1; while (size < N) size <<= 1; vector<Node> seg(2 * size); auto setLeaf = [&](int p, int weight) { for (int d = 0; d <= MAX_W; ++d) { seg[p].nxt[d] = static_cast<unsigned char>( d >= weight ? d - weight : weight - d ); } }; auto pull = [&](int p) { const auto &top = seg[p << 1].nxt; const auto &bottom = seg[p << 1 | 1].nxt; auto &res = seg[p].nxt; for (int d = 0; d <= MAX_W; ++d) { res[d] = top[bottom[d]]; } }; for (int i = 0; i < size; ++i) { if (i < N) { setLeaf(size + i, w[i]); } else { for (int d = 0; d <= MAX_W; ++d) { seg[size + i].nxt[d] = static_cast<unsigned char>(d); } } } for (int p = size - 1; p >= 1; --p) { pull(p); } auto answer = [&]() -> long long { return (totalWeight - seg[1].nxt[0]) / 2; }; cout << answer() << '\n'; while (Q--) { int P, Z; cin >> P >> Z; totalWeight += Z - w[P]; w[P] = Z; int p = size + P; setLeaf(p, Z); while ((p >>= 1) != 0) { pull(p); } cout << answer() << '\n'; } return 0; }
Kimi K3.1 Pro · 采样 2 · 82 行
#include <bits/stdc++.h> using namespace std; constexpr int MAXW = 50; constexpr int STATES = MAXW + 1; struct Node { int add[STATES]; unsigned char nxt[STATES]; }; inline void makeLeaf(Node &node, int w) { for (int d = 0; d < STATES; ++d) { node.add[d] = max(0, w - d); node.nxt[d] = static_cast<unsigned char>(abs(d - w)); } } inline void makeIdentity(Node &node) { for (int d = 0; d < STATES; ++d) { node.add[d] = 0; node.nxt[d] = static_cast<unsigned char>(d); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> w(N); for (int &x : w) cin >> x; int size = 1; while (size < N) size <<= 1; vector<Node> seg(2 * size); for (int i = 0; i < size; ++i) { if (i < N) makeLeaf(seg[size + i], w[i]); else makeIdentity(seg[size + i]); } auto pull = [&](int p) { const Node &left = seg[p << 1]; const Node &right = seg[p << 1 | 1]; Node &out = seg[p]; for (int d = 0; d < STATES; ++d) { int mid = right.nxt[d]; out.nxt[d] = left.nxt[mid]; out.add[d] = right.add[d] + left.add[mid]; } }; for (int p = size - 1; p >= 1; --p) pull(p); auto currentAnswer = [&]() -> int { return seg[1].add[0] - static_cast<int>(seg[1].nxt[0]); }; cout << currentAnswer() << '\n'; while (Q--) { int p, z; cin >> p >> z; int at = size + p; makeLeaf(seg[at], z); while (at > 1) { at >>= 1; pull(at); } cout << currentAnswer() << '\n'; } return 0; }
Kimi K3.1 Pro · 采样 3 · 82 行
#include <bits/stdc++.h> using namespace std; static constexpr int MAXW = 50; struct Node { int add[MAXW + 1]; unsigned char nxt[MAXW + 1]; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> w(N); for (int &x : w) cin >> x; int size = 1; while (size < N) size <<= 1; vector<Node> tree(2 * size); auto setLeaf = [&](int v, int weight) { Node &nd = tree[v]; for (int d = 0; d <= MAXW; ++d) { if (weight >= d) { nd.add[d] = d; nd.nxt[d] = static_cast<unsigned char>(weight - d); } else { nd.add[d] = weight; nd.nxt[d] = static_cast<unsigned char>(d - weight); } } }; auto setIdentity = [&](int v) { Node &nd = tree[v]; for (int d = 0; d <= MAXW; ++d) { nd.add[d] = 0; nd.nxt[d] = static_cast<unsigned char>(d); } }; auto pull = [&](int v) { const Node &left = tree[v << 1]; const Node &right = tree[v << 1 | 1]; Node &cur = tree[v]; for (int d = 0; d <= MAXW; ++d) { int middle = right.nxt[d]; cur.add[d] = right.add[d] + left.add[middle]; cur.nxt[d] = left.nxt[middle]; } }; for (int i = 0; i < size; ++i) { if (i < N) setLeaf(size + i, w[i]); else setIdentity(size + i); } for (int v = size - 1; v >= 1; --v) pull(v); cout << tree[1].add[0] << '\n'; while (Q--) { int p, z; cin >> p >> z; w[p] = z; int v = size + p; setLeaf(v, z); for (v >>= 1; v >= 1; v >>= 1) { pull(v); if (v == 1) break; } cout << tree[1].add[0] << '\n'; } return 0; }
DeepSeek Flash V4.1-1017 · 采样 1 · 80 行
#include <bits/stdc++.h> using namespace std; constexpr int MAXD = 50; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> W(N); long long sum = 0; for (int i = 0; i < N; ++i) { cin >> W[i]; sum += W[i]; } int base = 1; while (base < N) base <<= 1; vector<array<unsigned char, MAXD + 1>> seg(2 * base); auto setLeaf = [&](int pos, int w) { int idx = base + pos; for (int d = 0; d <= MAXD; ++d) { seg[idx][d] = static_cast<unsigned char>(abs(d - w)); } }; for (int i = 0; i < base; ++i) { int idx = base + i; if (i < N) { for (int d = 0; d <= MAXD; ++d) { seg[idx][d] = static_cast<unsigned char>(abs(d - W[i])); } } else { for (int d = 0; d <= MAXD; ++d) { seg[idx][d] = static_cast<unsigned char>(d); } } } auto pull = [&](int idx) { for (int d = 0; d <= MAXD; ++d) { seg[idx][d] = seg[idx * 2][seg[idx * 2 + 1][d]]; } }; for (int idx = base - 1; idx >= 1; --idx) { pull(idx); } auto getAnswer = [&]() -> long long { int d = seg[1][0]; return (sum - d) / 2; }; cout << getAnswer() << '\n'; while (Q--) { int P, Z; cin >> P >> Z; sum += Z - W[P]; W[P] = Z; setLeaf(P, Z); for (int idx = (base + P) >> 1; idx >= 1; idx >>= 1) { pull(idx); } cout << getAnswer() << '\n'; } return 0; }
DeepSeek Flash V4.1-1017 · 采样 2 · 84 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> W(N); long long total = 0; for (int i = 0; i < N; ++i) { cin >> W[i]; total += W[i]; } int size = 1; while (size < N) size <<= 1; vector<array<unsigned char, 51>> seg(2 * size); // Identity transformation for unused leaves. for (int v = 0; v < 2 * size; ++v) { for (int d = 0; d <= 50; ++d) { seg[v][d] = static_cast<unsigned char>(d); } } auto setLeaf = [&](int pos, int w) { int v = size + pos; for (int d = 0; d <= 50; ++d) { seg[v][d] = static_cast<unsigned char>(abs(d - w)); } }; auto pull = [&](int v) { auto &res = seg[v]; auto &left = seg[v << 1]; auto &right = seg[v << 1 | 1]; // Process right child first, then left child. for (int d = 0; d <= 50; ++d) { res[d] = left[right[d]]; } }; for (int i = 0; i < N; ++i) { setLeaf(i, W[i]); } for (int v = size - 1; v >= 1; --v) { pull(v); } auto getAnswer = [&]() -> long long { int diff = seg[1][0]; return (total - diff) / 2; }; cout << getAnswer() << '\n'; while (Q--) { int p, z; cin >> p >> z; total += z - W[p]; W[p] = z; setLeaf(p, z); int v = (size + p) >> 1; while (v >= 1) { pull(v); if (v == 1) break; v >>= 1; } cout << getAnswer() << '\n'; } return 0; }
DeepSeek Flash V4.1-1017 · 采样 3 · 81 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> W(N); long long total = 0; for (int i = 0; i < N; ++i) { cin >> W[i]; total += W[i]; } int sz = 1; while (sz < N) sz <<= 1; // seg[node][d] = resulting difference when applying this segment // to an incoming difference d, in bottom-to-top order. vector<array<unsigned char, 51>> seg(2 * sz); // Identity for unused leaves. for (int i = 0; i < sz; ++i) { for (int d = 0; d <= 50; ++d) { seg[sz + i][d] = static_cast<unsigned char>(d); } } // We process biscuits from bottom to top. for (int k = 0; k < N; ++k) { int w = W[N - 1 - k]; for (int d = 0; d <= 50; ++d) { seg[sz + k][d] = static_cast<unsigned char>(abs(d - w)); } } auto pull = [&](int p) { int l = p << 1; int r = l | 1; for (int d = 0; d <= 50; ++d) { seg[p][d] = seg[r][seg[l][d]]; } }; for (int p = sz - 1; p >= 1; --p) { pull(p); } auto get_answer = [&]() -> long long { int d = seg[1][0]; return (total - d) / 2; }; cout << get_answer() << '\n'; for (int qi = 0; qi < Q; ++qi) { int P, Z; cin >> P >> Z; total += static_cast<long long>(Z) - W[P]; W[P] = Z; int k = N - 1 - P; int leaf = sz + k; for (int d = 0; d <= 50; ++d) { seg[leaf][d] = static_cast<unsigned char>(abs(d - Z)); } for (int p = leaf >> 1; p >= 1; p >>= 1) { pull(p); } cout << get_answer() << '\n'; } return 0; }
MiniMax M3.1 Flash · 采样 1 · 102 行
#include <bits/stdc++.h> using namespace std; class SegmentTree { static constexpr int MAX_WEIGHT = 50; static constexpr int STATES = MAX_WEIGHT + 1; struct Node { uint8_t to[STATES]; int gain[STATES]; }; int base; vector<Node> tree; static void setLeaf(Node& node, int weight) { for (int d = 0; d < STATES; ++d) { node.to[d] = static_cast<uint8_t>(abs(d - weight)); node.gain[d] = min(d, weight); } } // The right segment is processed first, followed by the left segment. static void pull(Node& result, const Node& left, const Node& right) { for (int d = 0; d < STATES; ++d) { int middle = right.to[d]; result.to[d] = left.to[middle]; result.gain[d] = right.gain[d] + left.gain[middle]; } } public: explicit SegmentTree(const vector<int>& weights) { int n = static_cast<int>(weights.size()); base = 1; while (base < n) base <<= 1; tree.resize(base << 1); for (int i = 0; i < base; ++i) { Node& leaf = tree[base + i]; if (i < n) { setLeaf(leaf, weights[i]); } else { // Identity transformation for padded positions. for (int d = 0; d < STATES; ++d) { leaf.to[d] = static_cast<uint8_t>(d); leaf.gain[d] = 0; } } } for (int p = base - 1; p >= 1; --p) { pull(tree[p], tree[p << 1], tree[p << 1 | 1]); } } void update(int position, int weight) { int p = base + position; setLeaf(tree[p], weight); for (p >>= 1; p > 0; p >>= 1) { pull(tree[p], tree[p << 1], tree[p << 1 | 1]); } } int answer() const { return tree[1].gain[0]; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> weights(N); for (int& weight : weights) { cin >> weight; } SegmentTree segmentTree(weights); cout << segmentTree.answer() << '\n'; for (int i = 0; i < Q; ++i) { int position, newWeight; cin >> position >> newWeight; if (weights[position] != newWeight) { weights[position] = newWeight; segmentTree.update(position, newWeight); } cout << segmentTree.answer() << '\n'; } return 0; }
MiniMax M3.1 Flash · 采样 2 · 100 行
#include <bits/stdc++.h> using namespace std; class SegmentTree { static constexpr int K = 51; using Mapping = array<unsigned char, K>; int base; vector<Mapping> tree; array<Mapping, K> singleWeight; void pull(int node) { const Mapping &left = tree[node << 1]; const Mapping &right = tree[node << 1 | 1]; Mapping &result = tree[node]; // The bottom (right) segment is processed first. for (int x = 0; x < K; ++x) { result[x] = left[right[x]]; } } public: explicit SegmentTree(const vector<int> &weights) { int n = static_cast<int>(weights.size()); base = 1; while (base < n) base <<= 1; tree.resize(base << 1); for (int weight = 0; weight < K; ++weight) { for (int x = 0; x < K; ++x) { singleWeight[weight][x] = static_cast<unsigned char>(abs(x - weight)); } } for (int i = 0; i < base; ++i) { if (i < n) { tree[base + i] = singleWeight[weights[i]]; } else { // Empty segments have the identity transformation. for (int x = 0; x < K; ++x) { tree[base + i][x] = static_cast<unsigned char>(x); } } } for (int node = base - 1; node >= 1; --node) { pull(node); } } void update(int position, int weight) { int node = base + position; tree[node] = singleWeight[weight]; while (node > 1) { node >>= 1; pull(node); } } int difference() const { return tree[1][0]; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> weights(N); long long totalWeight = 0; for (int &weight : weights) { cin >> weight; totalWeight += weight; } SegmentTree segmentTree(weights); cout << (totalWeight - segmentTree.difference()) / 2 << '\n'; for (int i = 0; i < Q; ++i) { int position, newWeight; cin >> position >> newWeight; totalWeight += newWeight - weights[position]; weights[position] = newWeight; segmentTree.update(position, newWeight); cout << (totalWeight - segmentTree.difference()) / 2 << '\n'; } return 0; }
MiniMax M3.1 Flash · 采样 3 · 91 行
#include <bits/stdc++.h> using namespace std; class SegmentTree { static constexpr int STATES = 51; struct Node { array<uint8_t, STATES> next{}; array<int, STATES> gain{}; }; int n, base; vector<Node> tree; void setLeaf(int pos, int weight) { Node &leaf = tree[base + pos]; for (int d = 0; d < STATES; ++d) { leaf.next[d] = static_cast<uint8_t>(abs(d - weight)); leaf.gain[d] = min(d, weight); } } static void pull(Node &parent, const Node &left, const Node &right) { for (int d = 0; d < STATES; ++d) { int middle = left.next[d]; parent.next[d] = right.next[middle]; parent.gain[d] = left.gain[d] + right.gain[middle]; } } public: explicit SegmentTree(const vector<int> &weights) : n(static_cast<int>(weights.size())), base(1) { while (base < n) base <<= 1; tree.resize(base << 1); // Padding leaves represent the identity transformation. for (int i = base + n; i < 2 * base; ++i) { for (int d = 0; d < STATES; ++d) { tree[i].next[d] = static_cast<uint8_t>(d); } } // The game recurrence processes weights from bottom to top. for (int i = 0; i < n; ++i) { setLeaf(n - 1 - i, weights[i]); } for (int p = base - 1; p >= 1; --p) { pull(tree[p], tree[p << 1], tree[(p << 1) | 1]); } } void update(int pos, int weight) { setLeaf(pos, weight); for (int p = (base + pos) >> 1; p >= 1; p >>= 1) { pull(tree[p], tree[p << 1], tree[(p << 1) | 1]); } } int answer() const { return tree[1].gain[0]; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; vector<int> weights(N); for (int &w : weights) cin >> w; SegmentTree seg(weights); cout << seg.answer() << '\n'; while (Q--) { int P, Z; cin >> P >> Z; // Original top-to-bottom index P corresponds to bottom-to-top // position N - 1 - P. seg.update(N - 1 - P, Z); cout << seg.answer() << '\n'; } return 0; }