题面
来源:FrontierCS 官方 statement.txt,与模型收到的题面相同。
Problem:
Time limit: 3 seconds
Memory limit: 512 megabytes
The popular improv website Interpretation Impetus hosts regular improv contests and maintains a rating
of the best performers. However, since improv can often go horribly wrong, the website is notorious for
declaring improv contests unrated. It now holds a wager before each improv contest where the participants
try to predict whether it will be rated or unrated, and they are now more popular than the improv itself.
Izzy andnother participants take part in each wager. First, they each make their prediction, expressed as
1 (“rated”) or0 (“unrated”). Izzy always goes last, so she knows the predictions of the other participants
when making her own. Then, the actual competition takes place and it is declared either rated or unrated.
You need to write a program that will interactively play as Izzy. There will be m wagers held in 2021,
and Izzy’s goal is to minimize the number of wrong predictions after all those wagers. Izzy knows nothing about the other participants /emdash.cyr they might
somehow always guess correctly, or their predictions might be correlated. Izzy’s predictions, though, do
not affect the predictions of the other participants and the decision on the contest being rated or not /emdash.cyr in
other words, in each test case, your program always receives the same inputs, no matter what it outputs.
Interaction Protocol
First, a solution must read two integers n (1 ≤n ≤1000) and m (1 ≤m ≤10 000). Then, the solution
must process m wagers. For each of them, the solution must first read a string consisting of n 0s and 1s,
in which the i-th character denotes the guess of the i-th participant. Then, the solution must print Izzy’s
guess as 0 or 1. Don’t forget to flush the output after printing it! Then, the solution must read the actual
outcome, also as 0 or 1, and then proceed to the next wager, if this wasn’t the last one.
## Scoring
Let x be c, your number of wrong predictions. b is the smallest number of mistakes made by another participant. If b=0, award 100 for c=0 and 0 otherwise. The physical reference (the 60-point level) is a=b. Define the lower-band continuation:
L(x) = 60*max(0,(2*b-x)/b).
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.
Any prediction other than 0 or 1 is invalid, regardless of the other predictions.
There are 200 test cases in this problem.
Example
standard input standard output
3 4
000
1
100
1
001
0
111
1
0
0
1
1
Note
In the example, the participants made 1, 2, and 3 mistakes respectively, so b = 1. Izzy made 3 mistakes, giving L(3)=60*max(0,(2-3)/1)=0 and a score of 0 points.
Page 12 of 14
结果
Kimi K3.1 ProKimi
max
49.4
平均得分 ↑
- 49.4采样 1 · 部分分
- 22.2k平均输出 token(含思考) ↓
- 28.6输出速度 tokens/s ↑
- 778 秒延迟 ↓
Kimi K3.1 Pro(high)Kimi high
high
53.5
平均得分 ↑
- 53.5采样 1 · 部分分
- 12.1k平均输出 token(含思考) ↓
- 24.6输出速度 tokens/s ↑
- 495 秒延迟 ↓
DeepSeek Flash V4.1-1017DeepSeek
auto(high)
52.7
平均得分 ↑
- 52.7采样 1 · 部分分
- 23.9k平均输出 token(含思考) ↓
- 192.2输出速度 tokens/s ↑
- 125 秒延迟 ↓
MiniMax M3.1 FlashMiniMax
auto(max)
59.1
平均得分 ↑
- 59.1采样 1 · 部分分
- 49.9k平均输出 token(含思考) ↓
- 143.2输出速度 tokens/s ↑
- 350 秒延迟 ↓
↑ 越大越好,↓ 越小越好。得分 0–100,按官方时限判定,所有测试点都满分才算解出。CPU 时间 / 官方解为解出的答案在官方解最慢的 3 个测试点上的 CPU 时间之比(几何平均),只比较官方解至少需要 0.05 秒的题;复杂度按增长幂次相对官方解分类。判题与计分见 原理。
代码
Kimi K3.1 Pro · 采样 1 · 55 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; if (!(cin >> n >> m)) return 0; vector<int> losses(n, 0); mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const double logN = log(static_cast<double>(n) + 1.0); for (int round = 0; round < m; ++round) { string predictions; cin >> predictions; int bestLoss = *min_element(losses.begin(), losses.end()); double eta = min(4.0, sqrt(2.0 * logN / max(1, bestLoss))); double totalWeight = 0.0; double weightOne = 0.0; for (int i = 0; i < n; ++i) { double weight = exp(-eta * static_cast<double>(losses[i] - bestLoss)); totalWeight += weight; if (predictions[i] == '1') weightOne += weight; } double probabilityOne = weightOne / totalWeight; int guess; if (probabilityOne <= 0.0) { guess = 0; } else if (probabilityOne >= 1.0) { guess = 1; } else { double u = generate_canonical<double, 64>(rng); guess = (u < probabilityOne) ? 1 : 0; } cout << guess << endl; int outcome; cin >> outcome; for (int i = 0; i < n; ++i) { if (predictions[i] - '0' != outcome) ++losses[i]; } } return 0; }
Kimi K3.1 Pro(high) · 采样 1 · 149 行
#include <bits/stdc++.h> using namespace std; struct Expert { int type; int index; int inverted; }; struct BaseLearner { double eta; double decay; vector<double> weight; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<Expert> experts; experts.reserve(2 * n + 6); for (int i = 0; i < n; ++i) { experts.push_back({0, i, 0}); experts.push_back({0, i, 1}); } experts.push_back({1, 0, 0}); experts.push_back({1, 1, 0}); experts.push_back({2, 0, 0}); experts.push_back({2, 0, 1}); experts.push_back({3, 0, 0}); experts.push_back({3, 0, 1}); const int expertCount = (int)experts.size(); const vector<double> etas = {0.04, 0.16, 0.55, 2.0}; const int baseCount = (int)etas.size(); const int algorithmCount = 2 * baseCount; vector<BaseLearner> bases; for (double eta : etas) { bases.push_back({eta, exp(-eta), vector<double>(expertCount, 1.0)}); } vector<double> metaWeight(algorithmCount, 1.0); vector<double> probability(baseCount); vector<int> deterministic(baseCount); vector<unsigned char> prediction(expertCount); mt19937_64 rng(712367821); uniform_real_distribution<double> uniform(0.0, 1.0); int previousOutcome = 0; const double metaEta = 0.1; const double metaDecay = exp(-metaEta); for (int round = 0; round < m; ++round) { string s; cin >> s; int ones = 0; for (char c : s) ones += (c == '1'); int majority = (2 * ones > n) ? 1 : 0; for (int j = 0; j < expertCount; ++j) { const Expert &e = experts[j]; int p; if (e.type == 0) { p = (s[e.index] == '1'); if (e.inverted) p ^= 1; } else if (e.type == 1) { p = e.index; } else if (e.type == 2) { p = previousOutcome ^ e.inverted; } else { p = majority ^ e.inverted; } prediction[j] = (unsigned char)p; } for (int k = 0; k < baseCount; ++k) { double sum0 = 0.0, sum1 = 0.0; const vector<double> &w = bases[k].weight; for (int j = 0; j < expertCount; ++j) { if (prediction[j]) sum1 += w[j]; else sum0 += w[j]; } probability[k] = sum1 / (sum0 + sum1); deterministic[k] = (sum1 > sum0) ? 1 : 0; } double metaSum = 0.0; for (double w : metaWeight) metaSum += w; double p1 = 0.0; for (int k = 0; k < baseCount; ++k) { p1 += metaWeight[2 * k] * probability[k]; p1 += metaWeight[2 * k + 1] * deterministic[k]; } p1 /= metaSum; p1 = max(0.0, min(1.0, p1)); int answer = (uniform(rng) < p1) ? 1 : 0; cout << answer << '\n' << flush; int outcome; cin >> outcome; double maxMetaWeight = 0.0; for (int k = 0; k < baseCount; ++k) { double randomizedLoss = outcome ? 1.0 - probability[k] : probability[k]; double deterministicLoss = (deterministic[k] != outcome) ? 1.0 : 0.0; metaWeight[2 * k] *= exp(-metaEta * randomizedLoss); metaWeight[2 * k + 1] *= (deterministicLoss ? metaDecay : 1.0); maxMetaWeight = max(maxMetaWeight, metaWeight[2 * k]); maxMetaWeight = max(maxMetaWeight, metaWeight[2 * k + 1]); } if (maxMetaWeight < 1e-180) { for (double &w : metaWeight) w *= 1e180; } for (int k = 0; k < baseCount; ++k) { vector<double> &w = bases[k].weight; double decay = bases[k].decay; double maxWeight = 0.0; for (int j = 0; j < expertCount; ++j) { if (prediction[j] != outcome) w[j] *= decay; maxWeight = max(maxWeight, w[j]); } if (maxWeight < 1e-180) { for (double &x : w) x *= 1e180; } } previousOutcome = outcome; } return 0; }
DeepSeek Flash V4.1-1017 · 采样 1 · 108 行
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; int E = n + 3; // participants + const0 + const1 + majority vector<int> err(E, 0), cor(E, 0); // Priors for Beta distribution over error probability int K = 18; vector<double> alpha(K), beta(K); double qs[] = {0.001, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.98, 0.99, 0.995, 0.999}; for (int i = 0; i < 17; ++i) { double q = qs[i]; alpha[i] = 2.0 * q; beta[i] = 2.0 * (1.0 - q); } alpha[17] = 0.5; beta[17] = 0.5; vector<vector<double>> w(E, vector<double>(K, 1.0)); for (int t = 0; t < m; ++t) { string s; cin >> s; vector<int> pred(E); int sum = 0; for (int i = 0; i < n; ++i) { pred[i] = s[i] - '0'; sum += pred[i]; } pred[n] = 0; pred[n+1] = 1; pred[n+2] = (sum * 2 >= n) ? 1 : 0; double sum_w_p1 = 0.0; for (int e = 0; e < E; ++e) { int p = pred[e]; double err_e = err[e]; double cor_e = cor[e]; for (int j = 0; j < K; ++j) { double a = alpha[j]; double b = beta[j]; double T = err_e + cor_e + a + b; double p1; if (p == 1) { p1 = (cor_e + b) / T; } else { p1 = (err_e + a) / T; } sum_w_p1 += w[e][j] * p1; } } double sum_w = (t == 0) ? (double)E * K : 1.0; double P1 = sum_w_p1 / sum_w; int guess = (P1 > 0.5) ? 1 : 0; cout << guess << endl; int y; cin >> y; double total = 0.0; for (int e = 0; e < E; ++e) { int p = pred[e]; double err_e = err[e]; double cor_e = cor[e]; for (int j = 0; j < K; ++j) { double a = alpha[j]; double b = beta[j]; double T = err_e + cor_e + a + b; double likelihood; if (p == 1) { if (y == 1) likelihood = (cor_e + b) / T; else likelihood = (err_e + a) / T; } else { if (y == 1) likelihood = (err_e + a) / T; else likelihood = (cor_e + b) / T; } w[e][j] *= likelihood; total += w[e][j]; } if (p == y) ++cor[e]; else ++err[e]; } if (total > 0.0) { double inv = 1.0 / total; for (int e = 0; e < E; ++e) { for (int j = 0; j < K; ++j) { w[e][j] *= inv; } } } else { for (int e = 0; e < E; ++e) { for (int j = 0; j < K; ++j) { w[e][j] = 1.0; } } } } return 0; }
MiniMax M3.1 Flash · 采样 1 · 252 行
#include <bits/stdc++.h> using namespace std; struct TrieNode { int child[2]; int localIndex; TrieNode() : child{-1, -1}, localIndex(-1) {} }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; if (!(cin >> n >> m)) return 0; constexpr int CANDIDATES = 9; constexpr double FAST_DECAY = 0.50; constexpr double SLOW_DECAY = 0.90; constexpr double META_DECAY = 0.995; constexpr double EXPERT_RECENCY_DECAY = 0.99; vector<double> fastDecay(m + 1), slowDecay(m + 1); fastDecay[0] = slowDecay[0] = 1.0; for (int i = 1; i <= m; ++i) { fastDecay[i] = fastDecay[i - 1] * FAST_DECAY; slowDecay[i] = slowDecay[i - 1] * SLOW_DECAY; } vector<int> mistakes(n, 0); vector<double> recentMistakes(n, 0.0); double recentDenominator = 0.0; vector<int> historyNode(n, 0); vector<TrieNode> trie; trie.reserve(static_cast<size_t>(n) * m + 1); trie.emplace_back(); array<int, CANDIDATES> candidateMistakes{}; array<double, CANDIDATES> candidateRecentMistakes{}; int rated = 0, unrated = 0; for (int round = 0; round < m; ++round) { string guesses; if (!(cin >> guesses)) return 0; int minMistakes = *min_element(mistakes.begin(), mistakes.end()); double fastVotes[2] = {0.0, 0.0}; double slowVotes[2] = {0.0, 0.0}; double groupedVotes[2] = {0.0, 0.0}; double distinctLeaderVotes[2] = {0.0, 0.0}; double committeeVotes[2] = {0.0, 0.0}; int leaderCounts[2] = {0, 0}; int majorityCounts[2] = {0, 0}; double signedScore = 0.0; double recentSignedScore = 0.0; double outcomePrior = log((rated + 5.0) / (unrated + 5.0)); signedScore += outcomePrior; recentSignedScore += outcomePrior; vector<int> touchedNodes; vector<double> groupMaximum; vector<unsigned char> groupContainsLeader; touchedNodes.reserve(n); groupMaximum.reserve(n); groupContainsLeader.reserve(n); vector<int> nextNode(n); for (int i = 0; i < n; ++i) { int bit = guesses[i] - '0'; int gap = mistakes[i] - minMistakes; double fastWeight = fastDecay[gap]; double slowWeight = slowDecay[gap]; fastVotes[bit] += fastWeight; slowVotes[bit] += slowWeight; ++majorityCounts[bit]; if (mistakes[i] == minMistakes) { ++leaderCounts[bit]; } if (gap == 0) { committeeVotes[bit] += 1.0; } else if (gap == 1) { committeeVotes[bit] += 0.10; } int correct = round - mistakes[i]; double probability = (correct + 5.0) / (round + 10.0); double reliability = 0.0; if (probability > 0.55) { reliability = log(probability / (1.0 - probability)); } else if (probability < 0.35) { reliability = log(probability / (1.0 - probability)); } reliability = max(-1.5, min(1.5, reliability)); signedScore += reliability * (bit == 1 ? 1.0 : -1.0); double recentProbability = (recentDenominator - recentMistakes[i] + 5.0) / (recentDenominator + 10.0); double recentReliability = 0.0; if (recentProbability > 0.55 || recentProbability < 0.35) { recentReliability = log(recentProbability / (1.0 - recentProbability)); } recentReliability = max(-1.5, min(1.5, recentReliability)); recentSignedScore += recentReliability * (bit == 1 ? 1.0 : -1.0); int parent = historyNode[i]; int next = trie[parent].child[bit]; if (next == -1) { next = static_cast<int>(trie.size()); trie[parent].child[bit] = next; trie.emplace_back(); } nextNode[i] = next; int local = trie[next].localIndex; if (local == -1) { local = static_cast<int>(touchedNodes.size()); trie[next].localIndex = local; touchedNodes.push_back(next); groupMaximum.push_back(0.0); groupContainsLeader.push_back(0); } if (slowWeight > groupMaximum[local]) { groupedVotes[bit] += slowWeight - groupMaximum[local]; groupMaximum[local] = slowWeight; } if (mistakes[i] == minMistakes && !groupContainsLeader[local]) { groupContainsLeader[local] = 1; distinctLeaderVotes[bit] += 1.0; } } auto chooseByVotes = [&](double v0, double v1, int fallback) { constexpr double EPS = 1e-12; if (v0 > v1 + EPS) return 0; if (v1 > v0 + EPS) return 1; return fallback; }; int majorityPrediction = chooseByVotes( majorityCounts[0], majorityCounts[1], 0 ); int fastPrediction = chooseByVotes( fastVotes[0], fastVotes[1], majorityPrediction ); int slowPrediction = chooseByVotes( slowVotes[0], slowVotes[1], fastPrediction ); int groupedPrediction = chooseByVotes( groupedVotes[0], groupedVotes[1], fastPrediction ); int distinctLeaderPrediction = chooseByVotes( distinctLeaderVotes[0], distinctLeaderVotes[1], fastPrediction ); int leaderPrediction = chooseByVotes( leaderCounts[0], leaderCounts[1], fastPrediction ); int committeePrediction = chooseByVotes( committeeVotes[0], committeeVotes[1], fastPrediction ); int signedPrediction = fastPrediction; if (signedScore > 1e-12) { signedPrediction = 1; } else if (signedScore < -1e-12) { signedPrediction = 0; } int recentSignedPrediction = fastPrediction; if (recentSignedScore > 1e-12) { recentSignedPrediction = 1; } else if (recentSignedScore < -1e-12) { recentSignedPrediction = 0; } array<int, CANDIDATES> prediction{ distinctLeaderPrediction, leaderPrediction, groupedPrediction, slowPrediction, fastPrediction, committeePrediction, signedPrediction, recentSignedPrediction, majorityPrediction }; int chosen = 0; double bestMetaScore = numeric_limits<double>::infinity(); for (int j = 0; j < CANDIDATES; ++j) { double metaScore = candidateMistakes[j] + 0.5 * candidateRecentMistakes[j]; if (metaScore < bestMetaScore - 1e-12) { bestMetaScore = metaScore; chosen = j; } } cout << prediction[chosen] << '\n'; cout.flush(); int outcome; if (!(cin >> outcome)) return 0; for (int j = 0; j < CANDIDATES; ++j) { int wrong = (prediction[j] != outcome); candidateMistakes[j] += wrong; candidateRecentMistakes[j] = META_DECAY * candidateRecentMistakes[j] + wrong; } for (int i = 0; i < n; ++i) { int wrong = ((guesses[i] - '0') != outcome); mistakes[i] += wrong; recentMistakes[i] = EXPERT_RECENCY_DECAY * recentMistakes[i] + wrong; } recentDenominator = EXPERT_RECENCY_DECAY * recentDenominator + 1.0; if (outcome == 1) { ++rated; } else { ++unrated; } for (int i = 0; i < n; ++i) { historyNode[i] = nextNode[i]; } for (int node : touchedNodes) { trie[node].localIndex = -1; } } return 0; }