跳到正文

个人记录

20260714雅礼总结

XieMuzhu约 12 分钟
原文

这是 2026年7月14日 存档的第 3 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年7月14日
收录
2026年7月14日
更新
2026年11月12日
篇幅
约 12 分钟

版本

  1. v6当前
  2. v5
  3. v4
  4. v3
更早的 2 个版本
  1. v2
  2. v1

比赛基本情况

  • 比赛日期:20262026 年 77 月 1414 日
  • 比赛时长:8:308:30 ~ 11:3011:30,共 33 小时
  • 比赛得分:125125 分
  • 比赛排名:第 66 名

比赛整体回顾

前半部分写T2、T3\texttt{T2}、\texttt{T3}的时候,做的其实还挺顺畅的,T2\texttt{T2} 挺快就做完了,然后是 T3\texttt{T3},然后又去打了一个 T4\texttt{T4} 的暴力,最后想了大概一个半小时的 T1\texttt{T1},但可惜的是 T1\texttt{T1} 还是没有写出来。最后检查了一下。前半部分做下来还是相对轻松,都是 普及-\color{orange} \text{普及-},然后到后面做到 T1、T4\texttt{T1}、\texttt{T4} 的时候就相对来讲要多动一点脑筋了。

题目复盘

T1:P9124 [USACO23FEB] Bakery S

本题基本情况

  • 本题得分:00 分
  • 开始时间:9:509:50 左右
  • 结束时间:11:1511:15 左右
  • 总用时:9090分钟左右

初始思路

考场解题过程

考场代码

C++
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
int t, n, bis, cak;
struct node{
    int a, b, c, d;
}w[N];
bool cmp(node x, node y){
    return x.d > y.d;
}
void solve(){
    cin >> n >> bis >> cak;
    for(int i = 1; i <= n; i++){
        cin >> w[i].a >> w[i].b >> w[i].c;
        w[i].d = w[i].a * bis + w[i].b * cak - w[i].c;
    }
    sort(w + 1, w + n + 1, cmp);
    if(w[1].d <= 0){
        cout << "0\n";
        return;
    }
    int ans = 1e18;
    int least = ceil(w[1].d * 1.0 / w[1].a);
    for(int i = 1; i <= min(least, bis - 1); i++){
        int cake = floor((w[1].c - w[1].a * (bis - i)) * 1.0 / w[1].b);
        ans = min(ans, i + cak - cake);
    }
    cout << ans << '\n';
} 
signed main(){
    cin >> t;
    while(t--) solve();
    return 0;
}

赛后题解

补题代码

C++

复杂度分析

时间复杂度:O(NO(N log2(tc+tm))log_2(t_c+t_m))
空间复杂度:O(N)O(N)

本题收获

T2:P9958 [USACO19JAN] Shell Game B

本题基本情况

  • 本题得分:100100 分
  • 开始时间:8:408:40 左右
  • 结束时间:8:508:50 左右
  • 总用时:1010 分钟左右,比较水

初始思路(即为补题思路)

考虑到 1≤N≤1001 \le N \le 100,所以考虑暴力枚举。

考场解题过程(即为赛后题解)

枚举所有的初始石子位置,在每次枚举的过程中模拟交换操作,判断 gjg_j 底下是否为鹅卵石,如果是的话,分数加 11。

需要注意的是

枚举的时候,nutinut_i 会变化,所以我们得将 nutinut_i 拷贝到 butibut_i,然后操作完之后再拷贝回来

考场代码(即为补题代码)

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int n, ans, a[N], b[N], g[N], nut[4], but[4];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i] >> g[i];
    for(int i = 1; i <= n; i++)
        nut[i] = i;//初始位置
    for(int i = 1; i <= 3; i++){
        int score = 0;
        for(int j = 1; j <= 3; j++)
            but[j] = nut[j];//以防冲散,拷贝nut数组
        for(int j = 1; j <= n; j++){
            swap(nut[a[j]], nut[b[j]]);//交换位置
            if(nut[g[j]] == i) score++;//猜对了
        }
        for(int j = 1; j <= 3; j++)
            nut[j] = but[j];//拷贝回来
        ans = max(ans, score);//取最大分数
    }
    cout << ans;
    return 0;
}

复杂度分析

时间复杂度:O(N)O(N)
空间复杂度:O(N)O(N)

本题收获

以后可以多多使用这个拷贝的方法,虽说这道题没必要,可以直接在后面赋值 11 ~ 33。

T3:P9960 [USACO19JAN] Guess the Animal B

本题基本情况

  • 本题得分:2020 分
  • 开始时间:8:508:50 左右
  • 结束时间:9:159:15 左右
  • 总用时:2525 分钟左右

初始思路

考虑到最后能得到答案,肯定是因为在问完 22 个及以上的动物的相同特征之后,再来问一个特征,锁定对应的动物,模拟。

考场解题过程

维护 problemiproblem_i 表示对应的动物在问锁定问题之前

考场代码

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int n, ans, k[N], problem[N], ok[N];
string s[N][N];
map <string, int> mp;
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        string name;
        cin >> name >> k[i];
        for(int j = 1; j <= k[i]; j++){
            cin >> s[i][j];
            mp[s[i][j]]++;
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= k[i]; j++)
            if(mp[s[i][j]] > 1) problem[i]++;
    for(int i = 1; i <= n; i++)
        if((k[i] - problem[i]) > 0) ok[i] = problem[i] + 1;
        else ok[i] = problem[i];
    for(int i = 1; i <= n; i++)
        ans = max(ans, ok[i]);
    cout << ans;
    return 0;
}

赛后题解

补题代码

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int n, ans, k[N];
queue <string> q[N];
map <string, bool> mp[N];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        string name, s;
        cin >> name >> k[i];
        for(int j = 1; j <= k[i]; j++){
            cin >> s;
            q[i].push(s);
            mp[i][s] = true;
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++){
            if(j == i) continue;
            int cnt = 0;
            for(int p = 1; p <= k[i]; p++){
                cnt += mp[j][q[i].front()];
                q[i].push(q[i].front());
                q[i].pop();
            }
            ans = max(ans, cnt);
        }
    cout << ans + 1;
    return 0;
}

复杂度分析

时间复杂度:O(N2KlogN)O(N ^ 2KlogN)
空间复杂度:O(NO(N logN)logN)

本题收获

T4:T784195 [USACO13NOV] Pogo-Cow S 加强版

本题基本情况

  • 本题得分:55 分
  • 开始时间:9:159:15 左右
  • 结束时间:9:509:50 左右
  • 总用时:3030 分钟左右

初始思路

考场解题过程

考场代码

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int n, ans;
struct node{
    int pos, score;
}a[N];
bool cmp(node x, node y){
    return x.pos < y.pos;
}
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i].pos >> a[i].score;
    sort(a + 1, a + n + 1, cmp);
    for(int i = 1; i <= n; i++)
        for(int j = -1; j <= 1; j += 2){
            int scr = a[i].score, lst = a[i].pos, dis = 0;
            for(int k = i + j; k >= 1 && k <= n; k += j)
                if(abs(a[k].pos - lst) >= dis){
                    dis = abs(a[k].pos - lst);
                    scr += a[k].score;
                    lst = a[k].pos;
                }
            ans = max(ans, scr);
        }
    cout << ans;
    return 0;
}

赛后题解

补题代码

C++

复杂度分析

时间复杂度:O(N2)O(N ^ 2)
空间复杂度:O(N2)O(N ^ 2)

本题收获

整体反思

做得较好的地方

需要改进的地方

时间安排总结

感谢观看QwQ~