榜单:牛客比赛排名
TIP:提交处可查看别人过题代码
难度 | 签到题 | 普通题 | 中等题 | 难题 |
---|---|---|---|---|
题号 | A D H | B | E G J K L | C F I |
情况 | ✔ | ✔ | - | - |
全部资料:一至八届 GXCPC广西大学生程序设计竞赛 题目与题解
文章目录
签到题
A. Additive Combinatorics
加性组合
题目大意:
判断 C 是否是 A 和 B 的和集
解题思路:
官方题解PPT还没看到
博主补充:
双重循环,计算每一对元素的和,将和存入集合(集合会自动排序和去重)
参考代码c++:
#include<bits/stdc++.h>
using namespace std;
int main() {
int n1, n2, n3, x;
cin >> n1 >> n2 >> n3;
vector<int> a(n1), b(n2);
for (int &x : a) cin >> x;
for (int &x : b) cin >> x;
set<int> c;
while (n3--) cin >> x, c.insert(x);
set<int> temp;
for (int i : a) for (int j : b) temp.insert(i + j);
cout << (temp == c ? "YES" : "NO");
}
D. DeepSeek, DeepThink!
深度求索,深度思考!
题目大意:
修改输入的值(开头首字母改小写,末尾?改.),前面拼接一段值,最后输出
解题思路:
官方题解PPT还没看到
博主补充:
没啥好说的,字符串处理方式多种多样
参考代码c++:
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
getline(cin, s);
s.front() = tolower(s.front());
s.back() = '.';
cout << "Okay, so I want to figure out " << s;
}
H. Hollow Knight: Silksong
空洞骑士:丝之歌
题目大意:
其实就是,计算还有多少天发布游戏
解题思路:
官方题解PPT还没看到
博主补充:
想简化代码有很多种方式,闰年计算可以简化,
参考代码c++:
#include <iostream>
using namespace std;
bool is_leap(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
int main() {
int y, m, d;
cin >> y >> m >> d;
const int end_days = 261; // 2025-09-18是当年的第261天
int total = 0;
// 计算起始日期在当年的天数
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (is_leap(y)) days[2] = 29;
int start = d;
for (int i = 1; i < m; ++i) start += days[i];
if (y == 2025) {
total = end_days - start;
} else {
total = (is_leap(y) ? 366 : 365) - start; // 剩余天数
for (int yr = y + 1; yr < 2025; ++yr) { // 中间年份
total += is_leap(yr) ? 366 : 365;
}
total += end_days; // 加上2025年的天数
}
cout << total << endl;
return 0;
}
普通题
B. Beats
节拍
题目大意:
每个节拍开始的瞬间,不能有某个音符正在播放但还没有结束
解题思路:
官方题解PPT还没看到
博主补充:
记录前缀和,然后循环里判断(前缀和的写法可以优化)
参考代码c++:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200010],s[200010];
map<int,bool>m;
signed main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+a[i],m[s[i]]=1;
for(int i=1;i<=n;i++){
int k=s[i];
for(int j=2;;j++){
if(k*j>=s[n]){
cout<<k;
return 0;
}
if(!m.count(k*j))break;
}
}
}