2024 睿抗机器人开发者大赛CAIP-编程技能赛-专科组(省赛)解题报告 | 珂学家
2024年睿抗机器人开发者大赛CAIP编程技能赛专科组省赛题目涵盖了基础语法、API调用、模拟、STL容器使用等多个方面。比赛题目从简单的字符串处理到复杂的模拟问题,难度适中,适合专科学生。
·
前言
题解
24 睿抗机器人开发者大赛CAIP-编程技能赛-专科组(省赛),是陈越姐姐出的题,题意背景非常的友爱。
专科组的题和本科组比,落差有点大。感觉专科更多的是基础语法+API调用题。
RC-v1 我爱拼题啊
分值:5分
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << "wo3 ai4 pin1 ti2 a !" << endl;
return 0;
}
RC-v2 小白兔拔萝卜
分值: 10分
题意; 比大小
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
if (n >= m) {
cout << "Ba!" << endl;
cout << (n - m) << endl;
} else {
cout << "Suan4 le ba." << endl;
cout << (m - n) << endl;
}
return 0;
}
RC-v3 逆行
分值: 10分
题意: 间接比大小
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int pos = 0, neg = 0;
for (int i = 0; i < n; i++) {
int v;
cin >> v;
if (v > 0) pos++;
else neg++;
}
cout << min(pos, neg) << endl;
return 0;
}
RC-v4 翻炒字符串
分值: 15分
题型:字符串 API 题
涉及
- 字符串的翻转,reverse/swap
- 字符串的切片, substr
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
reverse(s.begin(), s.end());
if (s.length() % 2 == 0) {
s = s.substr(1, s.length() - 2);
} else {
int m = s.length() / 2;
s = s.substr(0, m) + s.substr(m + 1);
}
for (int i = 0; i < s.length(); i+=2) {
swap(s[i], s[i + 1]);
}
cout << s << endl;
return 0;
}
RC-v5 主菜与配菜
分值: 20分
题型: 模拟
这题有一定的码量,还会涉及一点小技巧,也就这样了。
#include <bits/stdc++.h>
using namespace std;
int consume(string &s, string &e) {
int x = atoi(s.substr(0, 2).c_str()) * 60 + atoi(s.substr(3, 2).c_str());
int y = atoi(e.substr(0, 2).c_str()) * 60 + atoi(e.substr(3, 2).c_str());
return y - x + 1;
}
int main() {
int n1, n2, n3;
cin >> n1 >> n2 >> n3;
vector<int> z(n1), p(n2), t(n3);
for (int &x: z) cin >> x;
for (int &x: p) cin >> x;
for (int &x: t) cin >> x;
string start, end;
int k;
cin >> start >> end >> k;
int tx = consume(start, end);
for (int i = 0; i < k; i++) {
int m;
cin >> m;
int mask = 0;
int tot = 0;
for (int j = 0; j < m; j++) {
string tab;
cin >> tab;
int no = atoi(tab.substr(1).c_str()) - 1;
if (tab[0] == 'Z') {
tot += z[no];
mask |= 1;
} else if (tab[0] == 'P') {
tot += p[no];
mask |= 2;
} else {
tot += t[no];
mask |= 4;
}
}
cout << (tx >= tot && mask == 7 ? "Yes" : "No") << endl;
}
return 0;
}
RC-v6 最受欢迎的书
分值:20分
题型:模拟
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, d;
cin >> n >> d;
vector<int> book(n), cnt(n);
for (int &x: book) cin >> x;
int maxBorrow = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < d; j++) {
int b, r;
cin >> b >> r;
book[i] = book[i] - b + r;
cnt[i] += b;
}
maxBorrow = max(maxBorrow, cnt[i]);
}
for (int i = 0; i < n; i++) {
cout << book[i];
if (maxBorrow == cnt[i]) cout << "*";
cout << endl;
}
return 0;
}
RC-v7 熊猫血
分值: 25
题型:stl容器的使用
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
set<string> blood;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
blood.insert(s);
}
int m;
cin >> m;
map<string, int> cnt;
int hit = 0;
string res;
for (int i = 0; i < m; i++) {
string s;
cin >> s;
if (blood.find(s) != blood.end()) {
cnt[s]++;
hit++;
res.push_back('1');
} else {
res.push_back('0');
}
}
cout << res << endl;
cout << std::fixed << std::setprecision(2) << (hit * 100.0 / m) << endl;
string ans = "";
int ansMax = 0;
for (auto [k, v]: cnt) {
if (v > ansMax) {
ansMax = v;
ans = k;
}
}
cout << ans << endl;
return 0;
}
唯一的难点,就是那个控制精度的语法了,感觉这个很少接触,要是真想不起来,我会用printf来控制精度输出。
写在最后

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)