版本比较
代码源考试总结(全集)
正文
增加 657 行删除 0 行
1,513 行未改动全部展开15141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321741,513 行未改动全部展开
暴力又又又又又炸了🤬!今天的时间管理中平,主要是今天的B对我而言思维和代码都有一点点难,但是这种题还是蛮好玩的🤡。
然后今天第三题其实还好,但是我对数学的敏感度还是不足😥,有待提升空间。其次暴力的正确度也要提升🚀。
# 暑假集训模拟赛 day5 (8.10)
## 前言
今天的题目也是非常的“食”💩,一上午都在改 B👿。连暴力都没时间写了,实则是没心情写了😵。哈哈哈哈哈!TYK A没删调试😜!
## 比赛基本情况
比赛日期 $2026.8.10$,比赛时常 $8:00-12:30$
预计分数:$100+100+20+0+0$
实际分数:$100+100+20+0+0$
代码源总榜排名:$rk65/300$
## 比赛整体回顾
:::info[具体做题时间]
- 8:00 开A题,10分钟左右想到思路
- 8:40 过了所有样例。
- 8:50 发现答案统计错误,思考如何处理。
- 9:10 想到新的解法,实践。
- 9:30 再次过了所有数据,提交开B。
- 9:40 想到解法,开始实践。
- 10:00 写完代码,开始调试。
- 10:20 找到第一个错误。
- 10:40 找到第二个错误。
- 10:45 找到第三个错误。
- 11:05 找到第四个错误。
- 11:20 找到第五个错误。
- 11:30 过了所有样例,提交。
- 12:00 打完了C题暴力,直接摆烂。
- 12:30 比赛结束
:::
整体感想:我讨厌改题😡,B题搬题人是ZRR,A也是恶心题,CCH还说是好题🤬!?感觉时间还是不太够用,总体时间分配也不平均🙄,也是跟B杠上了好吧!只能说至少今天没挂分😔。
## 题目复盘
### A. 对称风铃
前景提要:这一题有坑,需要多想一下🤔!
对于他的操作次数我们很好解决,就是对于每个线看他平行的有多少根😁,又因为绳子挂的点都不相同,所以我们很容易就可以想到,一定有方案可以使得每个绳子最多动一下👌。
那么我们问题就可以转换为如何解决约束矛盾的问题,其实也并不难,我们可以考虑建图来解决约束🙂,如果对于一个点他的一个断点的对应点属于一条线的点,那么这两条线就不能同时选了这条平行于标准的线,那么又因为所有点不同,边数与时间复杂度完全不会爆🤨!
:::info[考场代码]```cpp#include<bits/stdc++.h>
using namespace std;
const int MAXX = 1e6 + 5;
struct pp{ int x, y, z;} ans[MAXX];
int n, x[MAXX], y[MAXX], minn = INT_MAX, cnt, sum[MAXX], ID, vis[MAXX], X[MAXX], Y[MAXX], zrr, id[MAXX];vector<pair<int, int> > e[MAXX][2];
void dfs(int u, int id){ if(vis[u]) return; if(id == 0) ans[++cnt] = {u, y[u], Y[u]}; else ans[++cnt] = {u, x[u], X[u]}; vis[u] = 1; for(int i = 0; i < e[u][id].size(); i++){ dfs(e[u][id][i].first, e[u][id][i].second); }}
signed main(){ freopen("popipa.in", "r", stdin); freopen("popipa.out", "w", stdout); cin >> n; for(int i = 0; i < n; i++){ cin >> x[i] >> y[i]; sum[(x[i] + y[i]) % (2 * n)]++; id[x[i]] = id[y[i]] = i; } for(int i = 0; i < 2 * n; i++){ int tmp = n - sum[(i + ((i + 1) % (2 * n))) % (2 * n)]; if(tmp < minn) ID = (i + ((i + 1) % (2 * n))) % (2 * n), minn = tmp; } for(int i = 0; i < n; i++){ if((x[i] + y[i]) % (2 * n) == ID){ vis[i] = 1; continue; } zrr = i; Y[i] = (x[i] <= ID ? ID - x[i] : (ID + 2 * n) - x[i]); X[i] = (y[i] <= ID ? ID - y[i] : (ID + 2 * n) - y[i]); if(x[id[Y[i]]] == Y[i]) e[i][0].push_back({id[Y[i]], 1}); else if(y[id[Y[i]]] == Y[i]) e[i][0].push_back({id[Y[i]], 0}); if(x[id[X[i]]] == X[i]) e[i][1].push_back({id[X[i]], 1}); else if(y[id[X[i]]] == X[i]) e[i][1].push_back({id[X[i]], 0}); } for(int i = 0; i < n; i++){ if(!vis[i]) dfs(i, 0); } cout << cnt << '\n'; for(int i = 1; i <= cnt; i++){ cout << ans[i].x << " " << ans[i].y << " " << ans[i].z << '\n'; } return 0;}```:::
### B. 魔法石共鸣
这题也是与第一天的A非常的像好吧😍!但是调了我很久😨。
我们直接套路按位考虑,我们从高位往低位思考,如果有 $1$ 那么我们肯定我们要把 $1$ 放一边是最优的,所以我们就有了个基础贪心策略😄。
1. 我们先从最高位考虑,分到两个队列里面。
2. 对于现在这个位,如果为 $1$ 的序列里面的数这个位有 $1$,那么我们就将 $0$ 的序列中这个位为 $1$ 的数塞到 $1$ 序列中。
3. 对于现在这个位,如果为 $1$ 的序列里面的数这个位没 $1$,那么我们就将 $0$ 的序列中所有这个位为 $1$ 的数合并,使得他们永远都捆绑在一起,维护答案(合并也就是直接或运算即可)。
备注:这个代码需要处理很多例如边界😑,序列不为空的情况,也是写了我很久好吧🤮!
:::info[考场代码]```cpp#include<bits/stdc++.h>#define int long long
using namespace std;
const int MAXX = 4e5 + 5;
int a[MAXX], n, t, ans, vis[MAXX], k, tot;
void solve(){ cin >> n; ans = k = tot = 0; for(int i = 1; i <= n; i++){ cin >> a[i], vis[i] = 0; } sort(a + 1, a + 1 + n); int tmp = a[n]; while(tmp) tmp /= 2, k++; for(; k >= 1; k--){ int num = 0; for(int i = 1; i <= n; i++) num += ((a[i] >> (k - 1)) & 1); if(num < n && num != 0){ for(int i = 1; i <= n; i++) if((a[i] >> (k - 1)) & 1) vis[i] = 1, tot++; ans = (1 << (k - 1)), k--; break; } } for(; k >= 1 && tot < n - 1; k--){ int num = 0; for(int i = 1; i <= n; i++) if(vis[i] == 1) num += ((a[i] >> (k - 1)) & 1); if(num){ int xyz = 0; for(int i = 1; i <= n; i++) if(vis[i] == 0 && ((a[i] >> (k - 1)) & 1)) xyz++; if(tot + xyz == n) continue; for(int i = 1; i <= n; i++) if(vis[i] == 0 && ((a[i] >> (k - 1)) & 1)) vis[i] = 1, tot++; ans += (1 << (k - 1)); }else{ int zrr = 0; for(int i = 1; i <= n; i++) if(vis[i] == 0 && ((a[i] >> (k - 1)) & 1)) zrr = i; if(!zrr) continue; for(int i = 1; i < zrr; i++) if(vis[i] == 0 && ((a[i] >> (k - 1)) & 1)) vis[i] = 2, a[zrr] |= a[i], tot++; ans += (1 << (k - 1)); } } for(; k >= 1; k--){ int num1 = 0, num2 = 0; for(int i = 1; i <= n; i++) if(vis[i] == 1) num1 += ((a[i] >> (k - 1)) & 1); for(int i = 1; i <= n; i++) if(vis[i] == 0) num2 += ((a[i] >> (k - 1)) & 1); if((num1 && !num2) || (!num1 && num2)) ans += (1 << (k - 1)); } cout << ans << '\n';}
signed main(){ freopen("magic.in", "r", stdin); freopen("magic.out", "w", stdout); cin >> t; while(t--) solve(); return 0;}```:::
### C. 能量核心共鸣
这道题直接写暴力好吧😶。
:::info[考场代码]```cpp#include<bits/stdc++.h>#define int unsigned long long
using namespace std;
const int MAXX = 5e3 + 5;
int op[MAXX], l[MAXX], r[MAXX], x[MAXX], a[MAXX], n, q, ans, sum[MAXX], num[MAXX];
void solve1(){ for(int i = 1; i <= q; i++){ cin >> op[i]; if(op[i] == 1){ cin >> l[i] >> r[i] >> x[i]; for(int j = l[i]; j <= r[i]; j++) a[j] &= x[i]; }else if(op[i] == 2){ cin >> l[i] >> x[i]; a[l[i]] = x[i]; }else{ cin >> l[i] >> r[i]; sum[l[i]] = a[l[i]], num[r[i]] = a[r[i]]; for(int j = l[i] + 1; j <= r[i]; j++) sum[j] = sum[j - 1] & a[j]; for(int j = r[i] - 1; j >= l[i]; j--) num[j] = num[j + 1] & a[j]; ans = max(num[l[i] + 1], sum[r[i] - 1]); for(int j = l[i] + 1; j < r[i]; j++) ans = max(ans, sum[j - 1] & num[j + 1]); cout << ans << '\n'; } }}
void solve2(){ int sum1 = 0, sum2 = 0, sum3 = 0; for(int i = 1; i <= q; i++){ cin >> op[i]; if(op[i] == 1){ sum1++; cin >> l[i] >> r[i] >> x[i]; }else if(op[i] == 2){ sum2++; cin >> l[i] >> x[i]; }else{ sum3++; cin >> l[i] >> r[i]; } }}
signed main(){ freopen("energy.in", "r", stdin); freopen("energy.out", "w", stdout); cin >> n >> q; for(int i = 1; i <= n; i++) cin >> a[i]; if(n <= 5000) solve1(); else solve2(); return 0;}```:::
### D. 蜗蜗的零件仓库
这题不想看了,呜呜呜呜😭!
### E. 加一2.5
这题不想看了,呜呜呜呜😭!
## 整体反思
时间还是不够,调试代码能力太弱了😥,写代码也不够细心,做题前没有考虑代码的正确性😣。
其次我还是太菜了,没有能力考高分😟。
哎~菜就多练吧🏀!
# 暑假集训模拟赛 day6 (8.13)
## 前言
妈的今天又挂分了😡,足足挂了 $100$ 分,妈的我就是傻逼🤬。
:::error[比赛感想]我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。
我是傻逼🤬。:::
## 比赛基本情况
比赛日期 $2026.8.13$,比赛时常 $8:00-12:30$
预计分数:$100+100+100+0$
实际分数:$100+100+0+0$
代码源总榜排名:$rk150/300$
## 比赛整体回顾
:::info[具体做题时间]
- 8:00 开始做A。
- 8:10 想到一个错解
- 8:20 写了一半发现贪心有问题,改写法。
- 8:30 换写法。
- 8:50 过了所有样例提交,开B。
- 9:20 发现时间复杂度的特点。
- 9:30 想到写法
- 10:05 过了所有样例提交,开C。
- 10:10-11:40 思考ing.
- 11:45 想到正确写法,实践。
- 12:25 输出长度正确,提交。
- 12:30 公布成绩,遗憾离场。:::
整体感想:我是傻子😤,这次题目整体比较简单,而且只有四道题,我却考炸了😩。最后一次模拟赛也是遗憾离场好吧😞!呜呜呜呜😭。
## 题目复盘
### A. 蜗蜗的能量水晶
这一道题是送分题,我们先将数组排序,因为我们要让它的值最小所以我们可以想到最基础的贪心:我们只会选连续的两个数,这样才是最优的👍。
那我们直接选前 $n$ 小的即可吗🤔?
不是,因为对于选的数,他是有一个限制的。因为是最小值做差,我们若选的数字非常的后面这会导致我往里面塞的其他数太小了😮,所以对于我们选的第 $i$ 个数有区间 $[1,1+(i-1) \times 2k]$ 🤨。其实这里可以直接发现单调性二分答案,我一开始写了个线段树,贪心找点会影响两边的答案,会出问题,糖糖🍭。
:::info[考场代码]```cpp#include<bits/stdc++.h>#define int long long
using namespace std;
const int MAXX = 1e6 + 5;
int n, k, a[MAXX], num[MAXX], ans, N;
bool check(int x){ int cnt = 0; for(int i = 1; i <= N; i++){ if(num[i] <= x){ cnt++; if(i > 1 + (cnt - 1) * 2 * k) return 0; i++; } } return cnt >= n;}
signed main(){ freopen("crystal.in", "r", stdin); freopen("crystal.out", "w", stdout); cin >> n >> k; N = 2 * n * k - 1; for(int i = 1; i <= 2 * n * k; i++) cin >> a[i]; sort(a + 1, a + 1 + 2 * n * k); for(int i = 1; i <= N; i++) num[i] = a[i + 1] - a[i]; int l = 0, r = 1e9; while(l <= r){ int mid = (l + r) / 2; if(check(mid)) ans = mid, r = mid - 1; else l = mid + 1; } cout << ans << '\n'; return 0;} ```:::
### B. 观星
这道题我们可以惊奇的发现😯,他 $n,m$ 的总和不超过 $2000$ 所以综合一下 $t = 10$ 左右,所以 $nm^2$ 的时间复杂度完全可以过😍。
我们发现一个性质:一个人顺时针走,一个人逆时针走,且两个人步数相同,又因为这是一个环所以所有人的坐标值和再取模 $m$ 是不变的🤯,那么我们就可以写 DP 了,剩下步骤啥子都会写😊。
这道题的主要难点就是找到这个性质😄。
:::info[考场代码]```cpp#include<bits/stdc++.h>#define int long long
using namespace std;
const int MAXX = 2e2 + 5;
int n, m, k, a[MAXX], sum, h[MAXX][MAXX], dp[MAXX][MAXX], t, X;
void solve(){ cin >> n >> m >> X; for(int i = 1; i <= n; i++){ cin >> a[i]; a[i]--; sum += a[i]; } for(int i = 1; i <= n; i++){ for(int j = 0; j < m; j++) cin >> h[i][j]; } sum %= m; memset(dp, -0x7f, sizeof dp); dp[0][sum] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j < m; j++){ if(dp[i - 1][j] == dp[0][m + 1]) continue; for(int k = 0; k <= m; k++){ int tmp = k * X % m; dp[i][(j + tmp + m) % m] = max(dp[i][(j + tmp + m) % m], dp[i - 1][j] + h[i][(a[i] + tmp) % m]); dp[i][(j - tmp + m) % m] = max(dp[i][(j - tmp + m) % m], dp[i - 1][j] + h[i][(a[i] - tmp + m) % m]); } } } cout << dp[n][sum] << '\n';}
signed main(){ freopen("liel1a.in", "r", stdin); freopen("liel1a.out", "w", stdout); cin >> t; while(t--) solve(); return 0;}```:::
### C. 生日聚会
由于这个题目搭档保证唯一,我们先思考如何求搭档🤨。
对于一个点如果他现在出度为 $1$ 那么他与其连边。又由于题目保证其图是一个类似的二分图所以不存在基环,因此可以用 topu 就一定可以配对,这样搭档就求出来了😏,那么我们思考如何找连续的😶。
我一开始是这么想的,我们直接把搭档缩成一个点,然后再跑图。但是我们可以发现,如果这样子就不能保证其一定经过搭档边,所以还需改进😐。
但是如果我们构造的图就让他经过这条边即可,因此我想到了新的构图方法👌。
$$\newcommand{\px}[1]{\color{#1}{\rule{6pt}{6pt}}} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{3b5dc9} \px{3b5dc9} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{ef7d57} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffffff} \px{3b5dc9} \px{3b5dc9} \px{3b5dc9} \px{3b5dc9} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{3b5dc9} \px{3b5dc9} \px{3b5dc9} \px{3b5dc9} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{38b764} \px{38b764} \px{38b764} \px{ffffff} \px{ffffff} \px{1a1c2c} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{3b5dc9} \px{3b5dc9} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{1a1c2c} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{41a6f6} \px{41a6f6} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{1a1c2c} \px{41a6f6} \px{41a6f6} \px{41a6f6} \px{41a6f6} \px{ef7d57} \px{ef7d57} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{38b764} \px{1a1c2c} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{41a6f6} \px{41a6f6} \px{41a6f6} \px{41a6f6} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt]\px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffcd75} \px{ffcd75} \px{ffcd75} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{38b764} \px{38b764} \px{38b764} \px{ffffff} \px{ffffff} \px{1a1c2c} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{41a6f6} \px{41a6f6} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt]\px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{1a1c2c} \px{ffffff} \px{ffffff} \px{ffffff} \px{73eff7} \px{73eff7} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt]\px{ffffff} \px{ffffff} \px{ffffff} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{ef7d57} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{b13e53} \px{ffffff} \px{1a1c2c} \px{1a1c2c} \px{73eff7} \px{73eff7} \px{73eff7} \px{73eff7} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{73eff7} \px{73eff7} \px{73eff7} \px{73eff7} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{73eff7} \px{73eff7} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ef7d57} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt] \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \px{ffffff} \\[-6pt]$$
我们对于两个搭档点绿和黄,我们直接跨过绿连接绿的邻节点,就如图中橙色连边。由于缩点性质不变依然可以跑 topu 排序👍。
:::info[考场代码]```cpp#include<bits/stdc++.h>#define int long long
using namespace std;
const int MAXX = 2e6 + 5;
int n, m, in[MAXX], vis[MAXX], pre[MAXX], ans[MAXX], tot, u, v, id[MAXX], cnt, flag[MAXX], dp[MAXX], maxx, ID;pair<int, int> num[MAXX];vector<int> e[MAXX], G[MAXX];queue<int> q, Q;
signed main(){ freopen("party.in", "r", stdin); freopen("party.out", "w", stdout); cin >> n >> m; n *= 2; for(int i = 1; i <= m; i++){ cin >> u >> v; e[u].push_back(v), e[v].push_back(u); in[u]++, in[v]++; } for(int i = 1; i <= n; i++){ if(in[i] == 1) q.push(i); } while(!q.empty()){ int x = q.front(); q.pop(); for(int i = 0; i < e[x].size(); i++){ int y = e[x][i]; if(!id[y]){ id[x] = y, id[y] = x; for(int j = 0; j < e[id[x]].size(); j++){ in[e[id[x]][j]]--; if(in[e[id[x]][j]] == 1) q.push(e[id[x]][j]); } } } } for(int i = 1; i <= n; i++){ for(int j = 0; j < e[id[i]].size(); j++){ int y = e[id[i]][j]; if(y == i) continue; G[i].push_back(y); flag[y]++;// cout << i << " " << y << '\n'; } } for(int i = 1; i <= n; i++){ if(flag[i] == 0) Q.push(i); } while(!Q.empty()){ int x = Q.front(); Q.pop(); dp[x] += 2;// cout << x << " | " << dp[x] << '\n'; if(dp[x] > maxx) maxx = dp[x], ID = x; for(int i = 0; i < G[x].size(); i++){ int y = G[x][i]; flag[y]--; if(dp[y] < dp[x]) pre[y] = x, dp[y] = dp[x]; if(flag[y] == 0) Q.push(y); } } while(ID != 0){ ans[++tot] = ID; ans[++tot] = id[ID]; ID = pre[ID]; } cout << tot << '\n'; for(int i = tot; i >= 1; i--) cout << ans[i] << " "; return 0;}```:::
:::info[AC代码]```cpp#include<bits/stdc++.h>#define int long long
using namespace std;
const int MAXX = 2e6 + 5;
int n, m, in[MAXX], vis[MAXX], pre[MAXX], ans[MAXX], tot, u, v, id[MAXX], cnt, flag[MAXX], dp[MAXX], maxx, ID;pair<int, int> num[MAXX];vector<int> e[MAXX], G[MAXX];queue<int> q, Q;
signed main(){// freopen("party.in", "r", stdin);// freopen("party.out", "w", stdout); cin >> n >> m; n *= 2; for(int i = 1; i <= m; i++){ cin >> u >> v; e[u].push_back(v), e[v].push_back(u); in[u]++, in[v]++; } for(int i = 1; i <= n; i++){ if(in[i] == 1) q.push(i); } while(!q.empty()){ int x = q.front(); q.pop(); for(int i = 0; i < e[x].size(); i++){ int y = e[x][i]; if(!id[y]){ id[x] = y, id[y] = x; for(int j = 0; j < e[id[x]].size(); j++){ in[e[id[x]][j]]--; if(in[e[id[x]][j]] == 1) q.push(e[id[x]][j]); } } } } for(int i = 1; i <= n; i++){ for(int j = 0; j < e[id[i]].size(); j++){ int y = e[id[i]][j]; if(y == i) continue; G[i].push_back(y); flag[y]++;// cout << i << " " << y << '\n'; } } for(int i = 1; i <= n; i++){ if(flag[i] == 0) Q.push(i); } while(!Q.empty()){ int x = Q.front(); Q.pop(); dp[x] += 2;// cout << x << " | " << dp[x] << '\n'; if(dp[x] > maxx) maxx = dp[x], ID = x; for(int i = 0; i < G[x].size(); i++){ int y = G[x][i]; flag[y]--; if(dp[y] < dp[x]) pre[y] = x, dp[y] = dp[x]; if(flag[y] == 0) Q.push(y); } } while(ID != 0){ ans[++tot] = id[ID]; ans[++tot] = ID; ID = pre[ID]; } cout << tot << '\n'; for(int i = tot; i >= 1; i--) cout << ans[i] << " "; return 0;}```:::
没错就是因为输出顺序导致的,还我 $100$ 分🙁。
### D. 蜗蜗的星际帝国
C 题都没调出来写个蛋啊😢!
## 整体反思
今天挂了本学期最多的一次挂分,也是荣誉再次拿下倒数了😨。
感觉自己的思维和对算法的运用能力还要加强😑。
自我感觉粗心错误以无药可救💀。