版本比较
震惊!咕噜咕噜最新模型CSP-S2025成绩,结果令人忍俊不禁
正文
增加 92 行删除 88 行
12345625 行未改动3233343536373839404114 行未改动5657585956606162636064656667646869706771727374753 行未改动798081827983848586878885899091929394959693979899100971011021031041055 行未改动11111211311411111511611311711811912012111812212312412512632 行未改动15916016116215916316416516616716816516917017117217317417117517617717817918 行未改动19819920020119820220320420520620720820920621021121221321413 行未改动2282292302312282322332342352363 行未改动2402412422432402442452462472442482492502512522532542552562572542582592562602612622632602642652662632672682692702672712722692732742752762772782792762802812822832842 行未改动28728828929028729129229329429531 行未改动3273283293303273313323333343357 行未改动34334434534634334434734834935035135261 行未改动4144154164174144184194204214225 行未改动4284294304314284324334344354364374384394404414384424434444454424464474484494504514524494534544554564574584554594604614624594634644654664674684654694704714724694734744754764734774784794764804814824834804844854864874884854894904914924934944914954964974984995005014985025035005045055065075085055095105115125138 行未改动52252352452552252652752852552953053152853253353453553653753453853954054154254354054454554654754454854955055154855255355455555655755455855956056155856256356456556656356756856957057157257357457157557657757457857958058158258358058458558658358758858958659059159259359459159559659759859559960060160260360060460560660760460860961061161255 行未改动6686696706716686726736746756763 行未改动68068168268368068468568668768810 行未改动6997007017026997037047057067079 行未改动7177187197207177217227237247217257267277287257297307317327334 行未改动73873974074173874274374474574274674774874975075174875275375475575675775475875976076176275976376476576276676776876977077177276977377477577277677777477877978077778178278378478578278678778878979078779179279379079479579679779879980079780180280380480580280680780880580981081181281321 行未改动【提示】:此处只用于测试目的(且未提交至自测赛)。比赛中请勿使用 AI 辅助参赛。
模型为`gemini-3-pro-preview`使用`roo code`插件完成测试.
未开启联网功能.
25 行未改动| road | 2025-11-23 13:09 | 100 | 80| replace | 2025-11-23 13:05 | 100 | 100| employ | 2025-11-23 13:03 | 100 | 100
按这个水平可以进省队,全国大概是150名左右(
附答题代码:
club:::info[code]14 行未改动
void solve() { int n; if (!(cin >> n)) return;
vector<Person> people(n); vector<int> count(3, 0); long long total_sat = 0;
for (int i = 0; i < n; ++i) { people[i].id = i; cin >> people[i].a[0] >> people[i].a[1] >> people[i].a[2];
int best = -1; int val = -1;
// Find preferred department (0-indexed) if (people[i].a[0] >= people[i].a[1] && people[i].a[0] >= people[i].a[2]) { best = 0; val = people[i].a[0];3 行未改动 } else { best = 2; val = people[i].a[2]; }
people[i].best_dept = best; people[i].best_val = val; count[best]++; total_sat += val; }
int overloaded_dept = -1; for (int i = 0; i < 3; ++i) { if (count[i] > n / 2) { overloaded_dept = i; break; } }
if (overloaded_dept != -1) { int remove_count = count[overloaded_dept] - n / 2; vector<int> losses;
for (int i = 0; i < n; ++i) { if (people[i].best_dept == overloaded_dept) { // Find best alternative int alt_val = -1;5 行未改动 } losses.push_back(people[i].best_val - alt_val); } }
sort(losses.begin(), losses.end());
for (int i = 0; i < remove_count; ++i) { total_sat -= losses[i]; } }
cout << total_sat << endl;}
int main() {32 行未改动
struct DSU { vector<int> parent; int components;
DSU(int n) { parent.resize(n + 1); iota(parent.begin(), parent.end(), 0); components = n; }
int find(int i) { if (parent[i] == i) return i; return parent[i] = find(parent[i]); }
bool unite(int i, int j) { int root_i = find(i); int root_j = find(j); if (root_i != root_j) {18 行未改动 }
// Precompute MST of original graph to reduce edges sort(orig_edges.begin(), orig_edges.end());
vector<Edge> reduced_edges; DSU dsu_orig(n); for (const auto& e : orig_edges) { if (dsu_orig.unite(e.u, e.v)) { reduced_edges.push_back(e); } }
// Read towns data struct Town { long long c; vector<long long> a; // a[i] is cost to city i+113 行未改动 int total_masks = 1 << k; for (int mask = 0; mask < total_masks; ++mask) { long long current_base_cost = 0; vector<int> active_towns;
for (int j = 0; j < k; ++j) { if ((mask >> j) & 1) { current_base_cost += towns[j].c; active_towns.push_back(j);3 行未改动 // Collect edges // We use reduced_edges + edges from active towns vector<Edge> current_edges; current_edges.reserve(reduced_edges.size() + active_towns.size() * n);
for (const auto& e : reduced_edges) { current_edges.push_back(e); }
for (int town_idx : active_towns) { // Town node index: n + 1 + town_idx (0-based inside town_idx, 1-based in graph n+1..n+k) int u = n + 1 + town_idx; for (int i = 0; i < n; ++i) { // City node index: i + 1 int v = i + 1; current_edges.push_back({u, v, towns[town_idx].a[i]}); } }
sort(current_edges.begin(), current_edges.end());
// Run Kruskal // Total nodes: n + k (we can just map active towns to their indices) // But for DSU size, we can use n + k + 1 to be safe DSU dsu(n + k); DSU dsu(n + k); long long mst_cost = 0; int edges_count = 0;
// We need to connect all n cities AND all active towns. // Total vertices in component: n + active_towns.size() // Expected edges: n + active_towns.size() - 1
int target_edges = n + active_towns.size() - 1;
for (const auto& e : current_edges) { if (dsu.unite(e.u, e.v)) { mst_cost += e.w; edges_count++; } }
// Check if all cities are connected // We can check if edges_count == target_edges. // Assuming the graph of (cities + active towns) is connected. // The original cities are connected, and each town connects to all cities?2 行未改动 // Is it possible a town is NOT connected? // Only if we didn't pick any edge for it. // But if we didn't pick any edge, edges_count < target_edges. // So checking edges_count is sufficient.
if (edges_count == target_edges) { long long total = current_base_cost + mst_cost; if (min_total_cost == -1 || total < min_total_cost) { min_total_cost = total;31 行未改动 return h1 == other.h1 && h2 == other.h2; }};
const int MAX_TOTAL_LEN = 5000005; const int MAX_TOTAL_LEN = 5000005;const int MAX_NODES = MAX_TOTAL_LEN + 400005; // Heuristicconst int TRIE_WIDTH = 26;
// Global Trie arrays to reuse memory7 行未改动int inR[MAX_NODES], outR[MAX_NODES], timerR;
// String storage references// Store strings as (string*) and (start, len) to avoid copies?// Or just store string objects if N is small? // N is 2e5, total length large. // Or just store string objects if N is small?// N is 2e5, total length large.// We can use vector<string> global buffer.vector<string> string_pool;
struct Item {61 行未改动struct Event { int x, type; // x coordinate (L-Trie in time), type: 0=start rule, 1=query, 2=end rule int y1, y2; // range or point on R-axis. For query y1=y2. For rule [y1, y2]. int id; // for rules: dummy. for queries: query index.
bool operator<(const Event& other) const { if (x != other.x) return x < other.x; return type < other.type; // Process start, then query, then end }5 行未改动 for (const auto& item : items) { if (item.id == -1) rules.push_back(item); else queries.push_back(item); }
if (queries.empty()) return; if (rules.empty()) return; // Answers remain 0
// 2. Build Tries // Reset global counters nodes_cntL = 1; nodes_cntR = 1; memset(chL[1], 0, sizeof(chL[1])); memset(chR[1], 0, sizeof(chR[1]));
// Nodes mapping vector<pair<int, int>> rule_nodes(rules.size()); vector<pair<int, int>> query_nodes(queries.size());
// Helper to get reversed string auto get_rev = [](const string& s) { string r = s; reverse(r.begin(), r.end()); return r; };
// Insert Rules for (size_t i = 0; i < rules.size(); ++i) { // L-Trie: Reverse of L context string revL = get_rev(string_pool[rules[i].l_idx]); rule_nodes[i].first = insert(1, revL, chL, nodes_cntL);
// R-Trie: R context rule_nodes[i].second = insert(1, string_pool[rules[i].r_idx], chR, nodes_cntR); }
// Insert Queries for (size_t i = 0; i < queries.size(); ++i) { // L-Trie: Reverse of Query L string revL = get_rev(string_pool[queries[i].l_idx]); query_nodes[i].first = insert(1, revL, chL, nodes_cntL);
// R-Trie: Query R query_nodes[i].second = insert(1, string_pool[queries[i].r_idx], chR, nodes_cntR); }
// 3. DFS ranges timerL = 0; dfs(1, chL, inL, outL, timerL);
timerR = 0; dfs(1, chR, inR, outR, timerR);
// 4. Sweep-line vector<Event> events; events.reserve(rules.size() * 2 + queries.size());
// Rule events: Rectangle [inL, outL] x [inR, outR] for (size_t i = 0; i < rules.size(); ++i) { int u = rule_nodes[i].first; int v = rule_nodes[i].second;
// Start of rectangle at inL[u] events.push_back({inL[u], 0, inR[v], outR[v], -1}); // End of rectangle at outL[u] events.push_back({outL[u], 2, inR[v], outR[v], -1}); }
// Query events: Point (inL[u], inR[v]) for (size_t i = 0; i < queries.size(); ++i) { int u = query_nodes[i].first; int v = query_nodes[i].second; events.push_back({inL[u], 1, inR[v], inR[v], queries[i].id}); }
sort(events.begin(), events.end());
// Process bit_n = timerR; // Reset BIT for (int i = 0; i <= bit_n; ++i) bit[i] = 0;
for (const auto& ev : events) { if (ev.type == 0) { // Start Rule update(ev.y1, 1); update(ev.y2 + 1, -1);8 行未改动
int main() { ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, q; if (!(cin >> n >> q)) return 0;
answers.resize(q, 0); string_pool.reserve(2 * (n + q));
// Read Rules for (int i = 0; i < n; ++i) { string s1, s2; cin >> s1 >> s2; if (s1 == s2) continue; // Useless rule
// Find core diff int u = 0; while (u < s1.length() && s1[u] == s2[u]) u++; int v = s1.length() - 1; while (v >= 0 && s1[v] == s2[v]) v--;
// Core parts string coreA = s1.substr(u, v - u + 1); string coreB = s2.substr(u, v - u + 1);
// Context parts string ctxL = s1.substr(0, u); string ctxR = s1.substr(v + 1);
// Store int idxL = string_pool.size(); string_pool.push_back(ctxL); int idxR = string_pool.size(); string_pool.push_back(ctxR);
CoreHash h = compute_hash(coreA, coreB); groups[h].push_back({idxL, idxR, -1}); }
// Read Queries for (int j = 0; j < q; ++j) { string t1, t2; cin >> t1 >> t2;
if (t1.length() != t2.length()) { answers[j] = 0; continue; } if (t1 == t2) { // Problem statement says t1 != t2, so we assume 0 or handle it // "different strings t_{j,1}, t_{j,2}" answers[j] = 0; answers[j] = 0; continue; }
// Find core diff int u = 0; while (u < t1.length() && t1[u] == t2[u]) u++; int v = t1.length() - 1; while (v >= 0 && t1[v] == t2[v]) v--;
string coreS = t1.substr(u, v - u + 1); string coreT = t2.substr(u, v - u + 1);
string ctxL = t1.substr(0, u); string ctxR = t1.substr(v + 1);
int idxL = string_pool.size(); string_pool.push_back(ctxL); int idxR = string_pool.size(); string_pool.push_back(ctxR);
CoreHash h = compute_hash(coreS, coreT); groups[h].push_back({idxL, idxR, j}); }
// Process groups for (const auto& kv : groups) { solve_group(kv.second); }
for (int j = 0; j < q; ++j) { cout << answers[j] << "\n"; }
return 0;}```:::55 行未改动 cin.tie(NULL);
if (!(cin >> n >> m)) return 0; cin >> s;
for (int i = 0; i < n; ++i) { int val; cin >> val; if (val > n) val = n;3 行未改动 for (int i = n; i >= 0; --i) { if (i == n) C_gt[i] = 0; else C_gt[i] = C_gt[i+1] + C_counts[i+1]; }
// C_gt[j] is the count of people with c > j. // Specifically, sum(C_counts[x] for x = j+1 to n).
init_comb();10 行未改动
for (int i = 0; i < n; ++i) { int cur = i % 2; int nxt = (i + 1) % 2;
// Reset next for (int j = 0; j <= n; ++j) { for (int k = 0; k <= n; ++k) { dp[nxt][j][k] = 0;9 行未改动 for (int j = 0; j <= i; ++j) { int max_k = min(i, C_gt[j]); for (int k = 0; k <= max_k; ++k) { if (dp[cur][j][k] == 0) continue;
long long ways = dp[cur][j][k]; int total_robust = C_gt[j]; int rem_robust = total_robust - k;
int total_fragile = n - total_robust; int used_fragile = i - k; // Total used i, k are robust, rest fragile int rem_fragile = total_fragile - used_fragile;
// 1. Success Transition // Requires s[i] == '1' // Requires picking from Robust if (difficulty == 1) {4 行未改动 // No splitting since j doesn't change dp[nxt][j][next_k] = (dp[nxt][j][next_k] + ways * rem_robust) % MOD; } }
// 2. Failure Transition // Always increases j -> j+1 // Can we pick?
// Option A: Pick from Robust // Possible if difficulty == 0 (unconstrained) if (difficulty == 0) { if (rem_robust > 0) { int k_temp = k + 1;
// Now transition j -> j+1 // Robust set shrinks by removing {c = j+1} group int D = C_counts[j+1]; int total_R_prev = total_robust; // C_gt[j] int rem_R_prev = rem_robust; // at start of step
// We used k_temp from total_R_prev. // We need to split k_temp into x (from D) and k_new (from rest) // x ranges from max(0, k_temp - (total_R_prev - D)) to min(k_temp, D) // Actually, simplified bounds: 0 to D, check validity
// Optimization: Precompute limit int next_total_robust = C_gt[j+1]; // = total_R_prev - D
long long denom = nCr(total_R_prev, k_temp); long long invDenom = modInverse(denom);
for (int x = 0; x <= D; ++x) { if (x > k_temp) break; if (D - x > total_R_prev - k_temp) continue;
long long num = (nCr(D, x) * nCr(total_R_prev - D, k_temp - x)) % MOD; long long prob = (num * invDenom) % MOD;
int k_new = k_temp - x;
long long added = (ways * rem_robust) % MOD; added = (added * prob) % MOD;
dp[nxt][j+1][k_new] = (dp[nxt][j+1][k_new] + added) % MOD; } } }
// Option B: Pick from Fragile { if (rem_fragile > 0) { int k_temp = k;
int D = C_counts[j+1]; int total_R_prev = total_robust;
long long denom = nCr(total_R_prev, k_temp); long long invDenom = modInverse(denom);
for (int x = 0; x <= D; ++x) { if (x > k_temp) break; if (D - x > total_R_prev - k_temp) continue;
long long num = (nCr(D, x) * nCr(total_R_prev - D, k_temp - x)) % MOD; long long prob = (num * invDenom) % MOD;
int k_new = k_temp - x;
long long added = (ways * rem_fragile) % MOD; added = (added * prob) % MOD;
dp[nxt][j+1][k_new] = (dp[nxt][j+1][k_new] + added) % MOD; } } }21 行未改动