跳到正文

个人记录

总结(2026-8-25)

Zhouyanbo约 9 分钟
原文
文章信息与版本

文章信息

发布
2026年8月26日
收录
2026年8月27日
更新
2026年11月7日
篇幅
约 9 分钟

版本

  1. v1当前

模拟赛总结(可以以日期+总结命名 例如 20260714总结)

一、比赛基本情况

  • 比赛日期:8-25
  • 比赛时长:3h
  • 比赛得分:128
  • 比赛排名:22

二、比赛整体回顾

简要记录本场比赛的做题顺序、时间安排、比赛状态以及整体感受,对题目评价等。

看T1T1不会,T2T2秒了,T3T3写了个贪心骗分,T4T4不会

三、题目复盘

T1:photoshoot

  • 本题得分:0
  • 开始时间:8:30
  • 结束时间:8:40
  • 总用时:10min
初始思路

暴力,但发现实现不了

考场解题过程

55分钟敲了个代码,然后才后知后觉地发现实现不了。

考场代码
C++
赛后题解

考虑每个GG的位置有点复杂,不妨转化一下,HG代表11,GH代表00,这样可以把字符串转化成一个01串。目标让11最多。

补题代码
C++
#include<bits/stdc++.h>
using namespace std; 
int n; 
string s; 
vector<int>v; 
int main(){
	cin >> n >> s; 
    s = ' ' + s; 
	for(int i = 1; i <= n; i += 2) {
		if(s[i] != s[i + 1]) {
			if(s[i] == 'G' && s[i + 1] == 'H') v.push_back(1); 
            else v.push_back(0); 
        }
    }
	int cnt = 0; 
	for(int i = 1; i < v.size(); i++) if(v[i - 1] != v[i]) cnt++; 
	if(v.size() == 0) cout << cnt; 
	else cout << cnt + v[v.size() - 1]; 
	return 0; 	
}
复杂度
  • 时间复杂度:O(N)O(N)
  • 空间复杂度:O(N)O(N)
本题总结

如果问题的解法很复麻烦不妨转化一下

T2:Teleportation

  • 本题得分:100
  • 开始时间:8:40
  • 结束时间:9:20
  • 总用时:35min + 5min
初始思路

传送门?最短路!

考场解题过程

一开始看到传送门还以为是道最短路题,打了半天dijkstradijkstra板子,然后看了一眼输入…只有一个传送门。然后经过激烈的头脑风暴,得出了简单的代码。

考场代码
C++
#include <bits/stdc++.h>
using namespace std;
int a, b, x, y, dx, dxx, dxxx;
int main(){
    cin >> a >> b >> x >> y;
    dx = abs(x - a) + abs(y - b), dxx = abs(x - b) + abs(y - a), dxxx = abs(a - b);
    cout << min({dx, dxx, dxxx});
    return 0;
}
赛后题解

可以记录所有路径的长度,取min⁡\min即可。

补题代码
C++
同上
复杂度
  • 时间复杂度:O(1)O(1)
  • 空间复杂度:O(1)O(1)
本题总结

看清楚题目再写。

T3:Milk Scheduling

  • 本题得分:28
  • 开始时间:9:20
  • 结束时间:10:00
  • 总用时:40min
初始思路

哎这不贪心吗?

考场解题过程

先按时间从小到大排个序,如果时间相同按挤奶量从大到小排序。

考场代码
C++
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int n, t, ans;
struct node{
    int g, d;
}a[N];
bool cmp(node a, node b){
    if (a.d != b.d) return a.d < b.d;
    return a.g > b.g;
}
signed main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i].g >> a[i].d; 
    sort (a + 1, a + n + 1, cmp); 
    for (int i = 1; i <= n; i++){
        if (t >= a[i].d) continue;
        ans += a[i].g;
        t++;
    }
    cout << ans;
    return 0;
}
赛后题解

对于ii,如果aia_i能够选入序列,那肯定直接选。否则如果要选当aia_i,那就得删除一个已选的数。所以可以将当前数与已选数中的最小值进行比较,如果替换后能让总和更大,则进行替换。

因为选取的数都是满足位置限制的,删除任意一个数,会让靠后的数都往前移动,必然还是满足位置限制,所以是可行的。

由于nn较大,为了能够快速选出最小值,需要用优先队列来维护。

复杂度
  • 时间复杂度:O(NlogN)O(N log N)
  • 空间复杂度:O(N)O(N)
补题代码
C++
#include <bits/stdc++.h>
#define int long long
using namespace std; 
int n;
struct node{
    int d, g; 
}a[1000005]; 
bool cmp(node a,node b){
    if(a.d == b.d)return a.g > b.g;  
    return a.d < b.d; 
}
priority_queue<int>op; 
signed main(){
    cin >> n; 
    for(int i = 1; i <= n; i++) cin >> a[i].g >> a[i].d; 
    sort(a + 1,a + 1 + n,cmp); 
    int sum = 0, minn = INT_MAX, t = 1; 
    for(int i = 1; i <= n; i++){
        if(t <= a[i].d){
            t++; 
            sum += a[i].g; 
            op.push(-a[i].g); 
        }
        else{
            if(a[i].g > -op.top()){
                sum -= -op.top(); 
                op.pop(); 
                op.push(-a[i].g); 
                sum += a[i].g; 
            }
        }
    }
    cout << sum; 
    return 0; 
}
本题总结

emmm...emmm...不会写怎么办?

T4:

  • 本题得分:0
  • 开始时间:10:00
  • 结束时间:10:10
  • 总用时:10min
初始思路

看不懂

考场解题过程

看不懂

考场代码
C++
赛后题解

由于雨伞覆盖可以重叠,所以如果大雨伞的覆盖代价更小,则应该取代小雨伞的覆盖,因此,应该先按照覆盖长度对代价做一个后缀最小值。

由于每次覆盖都是一段区间,所以先对要覆盖的单位线段排序,然后按顺序进行覆盖,由此得到了状态可用的拓扑序,考虑用动态规划求解。

可以用 [i,c][i,c] 作为状态,表示覆盖前 ii 个线段需要 cc 的代价,枚举下一段要覆盖的区间作为转移,区间的左边界就是下一个要覆盖的线段,所以只需要枚举右边界即可。

补题代码
C++
#include<bits/stdc++.h>
using namespace std; 
int dp[100005], x[5005], c[100005], n, m; 
int main(){
    cin >> n >> m; 
    memset(dp, 0x3f, sizeof(dp)); 
    for(int i = 1; i <= n; i++) cin >> x[i]; 
    sort(x + 1, x + n + 1); 
    for(int i = 1; i <= m; i++) cin >> c[i]; 
    c[m + 1] = INT_MAX; 
    for(int i = m; i >= 1; i--) c[i] = min(c[i], c[i + 1]);    
    dp[0] = 0; 
    for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) dp[i] = min(dp[i], dp[j - 1] + c[x[i] - x[j] + 1]); 
    cout << dp[n]; 
    return 0; 
}
复杂度
  • 时间复杂度:O(N2+M)O(N^2 + M)
  • 空间复杂度:O(N+M)O(N+M)
本题总结

不要一上来就想着不会。

四、整体反思

做得较好的地方

无

需要改进的地方

后面浪费太多时间了。

时间安排总结

后面浪费太多时间了。

原文