2026-7-16 雅礼比赛总结
一、比赛基本情况
- 比赛日期:
2026-7-16 - 比赛时长:
8:30 \sim 11:30 ,共3 小时。 - 比赛得分:
100 - 比赛排名:
26 名。
二、比赛整体回顾
总体来说,T1 和 T3 比较简单,T2 和 T4 较难。最开始先去做了 T3,然后跟 T1 纠缠了
三、题目复盘(按题目难度排序)
T1:奶牛翻转
- 本题得分:
\color{green} 100 - 开始时间:
8:35 - 结束时间:
9:00 - 总用时:
25 分钟
初始思路
因为每一个数字为
考场解题过程
同上。
考场代码
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 15;
int a[N][N];
int main(){
//freopen("cowtip.in","r",stdin);
//freopen("cowtip.out","w",stdout);
int n;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
char c;
cin >> c;
a[i][j] = c - '0';
}
}
int ans = 0;
for(int i = n;i >= 1;i--){
for(int j = n;j >= 1;j--){
if(a[i][j] == 1){
ans++;
for(int x = 1;x <= i;x++){
for(int y = 1;y <= j;y++){
a[x][y] = !a[x][y];
}
}
}
}
}
cout << ans;
return 0;
}
复杂度
- 时间复杂度:
O(n^4) - 空间复杂度:
O(n^2)
本题总结
还可以,半小时就做出来了。
T2:空调
- 本题得分:
0 - 开始时间:
9:10 - 结束时间:
10:00 - 总用时:
50 分
初始思路
暴力枚举每个空调的摆放状态,如果不冲突就累加答案,最后对所有答案取最小值。最后发现错误原因是二进制是从
考场解题过程
同上。
考场代码
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 105;
int need[N],tmp[N];
int a[N],b[N],p[N],m2[N];
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i++){
int s,t,c;
cin >> s >> t >> c;
for(int j = s;j <= t;j++){
need[j] = max(need[j],c);
}
}
for(int i = 1;i <= m;i++){
cin >> a[i] >> b[i] >> p[i] >> m2[i];
}
int ans = 2e9;
for(int i = 0;i < (1 << m);i++){
memset(tmp,0,sizeof tmp);
int val = 0;
for(int j = 1;j <= m;j++){
if(i & (1 << j)){
val += m2[j];
for(int x = a[j];x <= b[j];x++){
tmp[x] += p[j];
}
}
}
bool ok = true;
for(int j = 1;j <= 100;j++){
if(tmp[j] < need[j]){
ok = false;
break;
}
}
if(ok){
ans = min(ans,val);
}
}
cout << ans;
return 0;
}
补题代码
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 105;
int need[N],tmp[N];
int a[N],b[N],p[N],m2[N];
int main(){
int n,m;
cin >> n >> m;
for(int i = 1;i <= n;i++){
int s,t,c;
cin >> s >> t >> c;
for(int j = s;j <= t;j++){
need[j] = max(need[j],c);
}
}
for(int i = 1;i <= m;i++){
cin >> a[i] >> b[i] >> p[i] >> m2[i];
}
int ans = 2e9;
for(int i = 0;i < (1 << m);i++){
memset(tmp,0,sizeof tmp);
int val = 0;
for(int j = 1;j <= m;j++){
if(i & (1 << (j - 1))){
val += m2[j];
for(int x = a[j];x <= b[j];x++){
tmp[x] += p[j];
}
}
}
bool ok = true;
for(int j = 1;j <= 100;j++){
if(tmp[j] < need[j]){
ok = false;
break;
}
}
if(ok){
ans = min(ans,val);
}
}
cout << ans;
return 0;
}
复杂度
- 时间复杂度:
O(2^m \times m) - 空间复杂度:
O(n)
本题总结
全是粗心错误,下次要好好检查。
T3:采浆果
- 本题得分:
0 - 开始时间:
10:10 - 结束时间:
10:45 - 总用时:
35 分
初始思路
开始毫无思路,就写了一个毫无技术含量的纯暴力。
考场解题过程
看题看了好久,写代码用了
考场代码
赛后题解
令较少的
考虑
考虑到题目中
复杂度
- 时间复杂度:
O(v \times n \times \log n) - 空间复杂度:
O(n)
补题代码
由于时间原因,还没有写补题代码。
T4:
- 本题得分:
0 - 开始时间:无
- 结束时间:无
- 总用时:无
初始思路
因为没时间了,就跳过去检查了。
赛后题解
可以用
仔细思考可以发现,因为只能往后走,所以状态是满足拓扑序的。而到达同一个
补题代码
由于时间原因,还没有写补题代码。
复杂度
- 时间复杂度:
O(n \times 2^b) - 空间复杂度:
O(n)
四、整体反思
做得较好的地方
在比赛最后检查了。
需要改进的地方
时间安排不合理,没有写最后一题。
时间安排总结
见上。