版本比较
10.18
正文
增加 713 行删除 0 行
204 行未改动全部展开205206207208204 行未改动全部展开cout << ans ;return 0 ;}```204 行未改动全部展开205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921204 行未改动全部展开cout << ans ;return 0 ;}```# 20261021## 一、比赛基本情况- 比赛日期:$2026.10.21$- 比赛时长:$14:00$至$17:00$,$3$个小时- 比赛得分:$1+1+1+0+1+0=4$- 比赛排名:$14$## 二、比赛整体回顾$B\to A\to C\to E$### A简单题### B简单题### C思维题### E思维题- - -## 三、题目复盘### A:CF1728C- **本题得分:$1$**#### 初始思路每次操作是将一个数变为它的位数,那么可以发现最多$2$次操作后会变成$1$。于是我们可以维护两个数组当前的最大值,每次进行比较,如果相等就跳过。如果不相等,将其中较大的那一个进行操作,变为它的位数,放回数组。具体操作可以用两个优先队列维护,每次比较队首的值进行以上操作,可以发现,每个数字最多入队3次。#### 考场解题过程非常顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n ;priority_queue <int> a , b ;long long len(long long x) {long long cnt = 0 ;while(x) {cnt ++ ;x /= 10 ;}return cnt ;}int main() {for(cin >> t ; t -- ;) {cin >> n ;a = b = priority_queue <int> () ;for(int i = 1 , x ; i <= n ; i ++) {cin >> x ;a.push(x) ;}for(int i = 1 , x ; i <= n ; i ++) {cin >> x ;b.push(x) ;}long long ans = 0 ;while (a.size()) {long long x = a.top() , y = b.top() ;if(x > y) {a.pop() ;a.push(len(x)) ;ans ++ ;} else if (x < y) {b.pop() ;b.push(len(y)) ;ans ++ ;} else {a.pop() ;b.pop() ;}}cout << ans << "\n" ;}return 0 ;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度- 时间复杂度:$O(n\log n)$- 空间复杂度:$O(n)$#### 本题总结### B:CF1646C- **本题得分:$1$**#### 初始思路我们发现对于任意一个数我们都可以用$popcount(x)$个数来完整,并且我们知道$<10^{12}$的阶乘数字只有$0$到$14$的阶乘,所以直接写个指数型dfs来枚举每阶乘的选择方案(你要写十五层循环我不拦你),然后去最小值#### 考场解题过程非常顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , fac[20] = {1} , minn ;long long popcount(long long x) {long long cnt = 0 ;while(x) {cnt ++ ;x -= (x & -x) ;}return cnt ;}void dfs(long long step , long long sum , long long cnt) {if(step > 15) {return ;}if(sum > n) {return ;}minn = min(minn , cnt + popcount(n - sum)) ;dfs(step + 1 , sum + fac[step] , cnt + 1) ;dfs(step + 1 , sum , cnt) ;}int main() {for(int i = 1 ; i <= 15 ; i ++) {fac[i] = fac[i - 1] * i ;}for(cin >> t ; t -- ;) {minn = 100 ;cin >> n ;dfs(0 , 0 , 0) ;cout << minn << "\n" ;}return 0 ;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度设$v=15$为阶乘数字的个数- 时间复杂度:$O(2^v)$- 空间复杂度:$O(1)$#### 本题总结### C:Cf1352G- **本题得分:$1$**#### 初始思路一眼构造#### 考场解题过程极其顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n ;int main() {for(cin >> t ; t -- ;) {cin >> n ;if(n < 4) {cout << "-1\n" ;} else if(n % 2 == 0) {for(int i = 2 ; i <= n ; i += 2) {cout << i << " " ;}cout << n - 3 << " " << n - 1 << " " ;for(int i = n - 5 ; i >= 1 ; i -= 2) {cout << i << " " ;}cout << "\n" ;} else {for(int i = 1 ; i <= n ; i += 2) {cout << i << " " ;}cout << n - 3 << " " << n - 1 << " " ;for(int i = n - 5 ; i >= 2 ; i -= 2) {cout << i << " " ;}cout << "\n" ;}}return 0 ;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度$v=1000$表示值域- 时间复杂度:$O(n)$- 空间复杂度:$O(1)$#### 本题总结### D:CF1486C- **本题得分:$0$**#### 初始思路#### 考场解题过程#### 考场代码#### 赛后题解用两个优先队列来维护以$1$结尾的和以$0$结尾的子序列的编号#### 补题代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , len , ans[200005] ;string s ;stack <int> c1 , c0 ;int main() {for(cin >> t ; t -- ;) {cin >> n >> s ;c1 = c0 = stack <int> () ;fill(ans + 1 , ans + n + 1 , len = 0) ;s = " " + s ;for(int i = 1 ; i <= n ; i ++) {if(s[i] == '0') {int now = (c1.empty() ? ++ len : c1.top()) ;if(c1.size()) {c1.pop() ;}c0.push(now) ;ans[i] = now ;} else {int now = (c0.empty() ? ++ len : c0.top()) ;if(c0.size()) {c0.pop() ;}c1.push(now) ;ans[i] = now ;}}cout << c0.size() + c1.size() << "\n" ;for(int i = 1 ; i <= n ; i ++) {cout << ans[i] << " " ;}cout << "\n" ;}return 0 ;}```#### 复杂度- 时间复杂度:$O(n)$- 空间复杂度:$O(n)$#### 本题总结### E:CF1795C- **本题得分:$1$**#### 初始思路可以把每个人看成一个点,朋友关系看成边。所以问题变成:删掉一些点,让剩下的边数为偶数,且删掉的点权值和最小,然后接下来就是分类讨论了#### 考场解题过程#### 考场代码```cpp line-numbers#include<bits/stdc++.h>using namespace std;long long n , m , x[100010] , y[100010] , a[100010] , ans , t ;vector<long long> g[100010] ;void solve() {cin >> n >> m ;for (long long i = 1 ; i <= n ; i ++) {cin >> a[i] ;g[i].clear() ;}for (long long i = 1 ; i <= m ; i ++) {cin >> x[i] >> y[i] ;g[x[i]].push_back(y[i]) ;g[y[i]].push_back(x[i]) ;}if (m % 2 == 0) {cout << "0\n" ;return ;}ans = 1e18 ;for (long long i = 1 ; i <= n ; i ++) {if (g[i].size() % 2 == 1) {ans = min(ans , a[i]) ;}}for (long long i = 1 ; i <= m ; i ++) {if ((g[x[i]].size() + g[y[i]].size()) % 2 == 0) {ans = min(ans, a[x[i]] + a[y[i]]) ;}}cout << ans << "\n" ;}int main() {for(cin >> t ; t -- ; solve()) ;return 0 ;}```#### 赛后题解我是对的#### 复杂度- 时间复杂度:$O(n)$- 空间复杂度:$O(n)$#### 补题代码我是对的#### 本题总结### F:CF1476C- **本题得分:$0$**#### 初始思路#### 考场解题过程#### 考场代码dp#### 赛后题解```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , c[100005] , a[100005] , b[100005] , dp[100005] , maxn ;int main() {for(cin >> t ; t -- ;) {cin >> n ;fill(dp , dp + n + 1 , maxn = 0) ;for(int i = 1 ; i <= n ; i ++) {cin >> c[i] ;}for(int i = 1 ; i <= n ; i ++) {cin >> a[i] ;}for(int i = 1 ; i <= n ; i ++) {cin >> b[i] ;}for(int i = 2 ; i <= n ; i ++) {if(a[i] > b[i]) {swap(a[i] , b[i]) ;}if(a[i] == b[i]) {dp[i] = c[i] + 1 ;} else {dp[i] = max((b[i] - a[i]) + 2 + (c[i] - 1) , dp[i - 1] - (b[i] - a[i]) + 2 + (c[i] - 1)) ;}maxn = max(maxn , dp[i]) ;}cout << maxn << "\n" ;}return 0 ;}```#### 补题代码#### 复杂度- 时间复杂度:$O(n^2)$- 空间复杂度:$O(n^2)$#### 本题总结## 四、整体反思### 做得较好的地方### 需要改进的地方### 时间安排总结还不错# 20261016## 一、比赛基本情况- 比赛日期:$2026.10.09$- 比赛时长:$14:00$至$16:30$,$2.5$个小时- 比赛得分:$1+0+0+1+1+1+0=4$- 比赛排名:$1$## 二、比赛整体回顾$E\to A\to D\to F$### A简单题### D简单贪心### E送分贪心### G简单题- - -### A:CF1560D- **本题得分:$1$**#### 初始思路注意到每个数字的最优答案一定不超过$10^{18}$,所以直接枚举每个$2$的幂次然后看差多少就行了#### 考场解题过程非常顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , minn ;string n , tgt[70] = {} ;void work(long long x) {long long sum = 0 , len = n.size() , m = tgt[x].size() ;for(int i = 0 ; i < len ; i ++){if(sum < m && n[i] == tgt[x][sum]) {sum ++ ;}}minn = min(minn , len + m - 2 * sum) ;}int main() {for(long long i = 0 ; i <= 60 ; i ++) {tgt[i] = to_string((1ll << i)) ;}for(cin >> t ; t -- ;) {cin >> n ;minn = 1e18 ;for(int i = 0 ; i <= 60 ; i ++) {work(i) ;}cout << minn << "\n" ;}return 0 ;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度设$n=10^18$表示值域- 时间复杂度:$O(\log n)$- 空间复杂度:$O(\log n)$#### 本题总结### B:CF1560E- **本题得分:$0$**#### 初始思路#### 考场解题过程#### 考场代码#### 赛后题解1. 第二问只需要把$t$倒过来看,字符出现的顺序就是被删掉的顺序的倒序2. 第一问只需要统计每一个字符的出现次数然后再除以他是在第几次的时候删掉的加起来就是原本字符串的长度#### 补题代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , len , anslen ;string s , ans , ans2 ;map <char , int> mp , cnt ;int main() {for(cin >> t ; t -- ;) {mp.clear() ;cnt.clear() ;cin >> s ;len = anslen = 0 ;ans2 = "" ;reverse(s.begin() , s.end()) ;for(char c : s) {if(!mp[c]) {mp[c] = ++ len ;ans2 = c + ans2 ;}cnt[c] ++ ;}reverse(s.begin() , s.end()) ;for(auto x : mp) {mp[x.first] = len - x.second + 1 ;anslen += cnt[x.first] / mp[x.first] ;}len = 0 ;ans = s.substr(0 , anslen) ;string t = "" ;while(ans != "") {t += ans ;int pos = 0 ;while(pos < ans.size()) {while(ans[pos] == ans2[len]) {ans.erase(pos , 1) ;}pos ++ ;}len ++ ;}if(t != s) {cout << "-1\n" ;} else {cout << s.substr(0 , anslen) << " " << ans2 << "\n" ;}}return 0 ;}```#### 复杂度- 时间复杂度:$O(n)$- 空间复杂度:$O(n)$#### 本题总结### C:CF1538F- **本题得分:$0$**#### 初始思路#### 考场解题过程#### 考场代码```cpp line-numbers```#### 赛后题解贪心#### 补题代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;int t , k ;string n ;int main() {cin >> t ;while (t --) {cin >> n >> k ;while(1) {set <char> have ;int pos = 0 ;for(char c : n) {have.insert(c) ;}if(have.size() <= k) {break ;}have = set <char> () ;for(int i = 0 ; i < n.size() ; i ++) {have.insert(n[i]) ;if(have.size() > k) {pos = i ;break ;}}while(pos && n[pos] == '9') {pos -- ;}n[pos] ++ ;for(int i = pos + 1 ; i < n.size() ; i ++) {n[i] = '0' ;}}cout << n << "\n" ;}return 0 ;}```#### 复杂度- 时间复杂度:$O(n)$- 空间复杂度:$O(n)$#### 本题总结### D:CF1547G- **本题得分:$1$**#### 初始思路每次选择社交能力最大的来搞#### 考场解题过程#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std;int t , n , ans , a[200005] ;pair<int , int> tot[200005] ;int main () {for(cin >> t ; t -- ;) {cin >> n ;priority_queue<pair<int , int>> q ;for (int i = 1 ; i <= n ; i ++) {cin >> a[i] ;if(a[i] > 0) {q.push({a[i] , i}) ;}}ans = 0 ;while(q.size() >= 2) {pair<int , int> u = q.top() ;q.pop() ;pair<int , int> v = q.top() ;q.pop() ;tot[++ ans] = {min(u.second , v.second) , max(u.second , v.second)} ;u.first -- ;v.first--;if(u.first) {q.push(u) ;}if(v.first) {q.push(v) ;}}cout << ans << "\n" ;for(int i = 1 ; i <= ans ; i ++) {cout << tot[i].first << " " << tot[i].second << "\n" ;}}return 0;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度- 时间复杂度:$O(n\log n)$- 空间复杂度:$O(n\log n)$#### 本题总结### E:CF1579E1- **本题得分:$1$**#### 初始思路我草,这贪心题太简单了吧#### 考场解题过程非常顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , p[200005] ;int main() {for(cin >> t ; t -- ;) {cin >> n ;for(int i = 1 ; i <= n ; i ++) {cin >> p[i] ;}deque <long long> dq ;dq.push_back(p[1]) ;for(int i = 2 ; i <= n ; i ++) {if(p[i] < dq.front()) {dq.push_front(p[i]) ;} else {dq.push_back(p[i]) ;}}while(dq.size()) {cout << dq.front() << " " ;dq.pop_front() ;}cout << "\n" ;}return 0 ;}```#### 赛后题解我是对的#### 复杂度- 时间复杂度:$O(1)$- 空间复杂度:$O(1)$#### 补题代码我是对的#### 本题总结### F:CF1551D2- **本题得分:$1$**#### 初始思路注意到每一个$0$都会让来到的$1$变成$0$#### 考场解题过程非常顺利#### 考场代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , a[1000005] , f[1000005] , d , maxn ;void bfs() {queue <long long> q ;for(int i = 0 ; i < n ; i ++) {if(a[i] == 0) {f[i] = 0 ;q.push(i) ;}}while(q.size()) {long long cur = q.front() ;q.pop() ;long long nxt = (cur + n - d) % n ;if(a[nxt]) {f[nxt] = f[cur] + 1 ;a[nxt] = 0 ;q.push(nxt) ;}}}int main() {for(cin >> t ; t -- ;) {cin >> n >> d ;maxn = 0 ;for(int i = 0 ; i < n ; i ++) {cin >> a[i] ;f[i] = 1e18 ;}bfs() ;for(int i = 0 ; i < n ; i ++) {maxn = max(maxn , f[i]) ;}cout << (maxn == 1e18 ? -1 : maxn) << "\n" ;}return 0 ;}```#### 赛后题解我是对的#### 补题代码我是对的#### 复杂度- 时间复杂度:$O(n)$- 空间复杂度:$O(n)$### G:CF1551E- **本题得分:$0$**#### 初始思路#### 考场解题过程#### 考场代码#### 赛后题解dp#### 补题代码```cpp line-numbers#include <bits/stdc++.h>using namespace std ;long long t , n , a[10005] , dp[10005][2005] , ans ;int main() {for(cin >> t ; t -- ;) {cin >> n ;fill(dp[0] , dp[n + 2] , 1e18) ;dp[1][0] = 0 ;ans = 114514 ;for(int i = 1 ; i <= n ; i ++) {cin >> a[i] ;}for(int i = 1 ; i <= n ; i ++) {for(int j = 0 ; j <= 2000 ; j ++) {if(dp[i][j] == 1e18) {continue ;}long long nj = max(0ll , j - a[i]) ;dp[i + 1][nj] = min(dp[i + 1][nj] , dp[i][j] + a[i]) ;if(j + a[i] <= 2000) {long long nk = max(0ll , dp[i][j] - a[i]) ;dp[i + 1][j + a[i]] = min(dp[i + 1][j + a[i]] , nk) ;}}}for(int i = 0 ; i <= 2000 ; i ++) {ans = min(ans , dp[n + 1][i] + i) ;}cout << ans << "\n" ;}return 0 ;}```#### 复杂度- 时间复杂度:$O(n^2)$- 空间复杂度:$O(n)$#### 本题总结## 四、整体反思### 做得较好的地方简单题手速快### 需要改进的地方### 时间安排总结