2024 睿抗机器人开发者大赛CAIP-编程技能赛-高职组(省赛)

写在前面

代码需要手动展开!!!
自己VP了一下CAIP高职组省赛
评价:题目十分简单,半小时AK,没什么知识点,全是语法题和模拟题

T1

输入样例:

输出样例:

wo3 ai4 pin1 ti2 a !

没啥好说的,直接输出

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    std::cout << "wo3 ai4 pin1 ti2 a !\n";
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T2

输入样例1:

99 66

输出样例1:

Ba!
33

输入样例2:

55 77

输出样例2:

Suan4 le ba.
22

比较一下,然后按要求输出即可,差值直接用abs

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    int a, b;
    std::cin >> a >> b;
    if (a >= b) {
        std::cout << "Ba!\n";
    }
    else {
        std::cout << "Suan4 le ba.\n";
    }
    std::cout << std::abs(a - b) << '\n';
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T3

输入样例:

7
85 -90 110 95 112 -120 -70

输出样例:

Suan4 le ba.
3

统计一下正负数的数量,输出min

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    int n;
    std::cin >> n;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i ++) {
        int x;
        std::cin >> x;
        if (x < 0) {
            cnt1 ++;
        }
        else {
            cnt2 ++;
        }
    }
    std::cout << std::min(cnt1, cnt2) << '\n';
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T4

输入样例1:

abcdefg

输出样例1:

fgceab

输入样例2:

abcdefgh

输出样例2:

fgdebc

按题目要求对字符串进行操作
第一步可以用reverse
第二步可以用substr
第三步直接遍历然后swap就可以

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    std::string s;
    std::cin >> s;
    std::reverse(all(s));
    int n = s.size();
    if (n & 1) {
        s = s.substr(0, n / 2) + s.substr(n / 2 + 1);
    }
    else {
        s = s.substr(1, n - 2);
    }
    for (int j = 0; j < s.size(); j += 2) {
        std::swap(s[j], s[j + 1]);
    }
    std::cout << s << '\n';
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T5

输入样例:

2 4 3
30 45
10 15 5 20
60 25 40
08:30 11:40 4
7 T1 Z2 P4 T3 P1 P2 Z1
4 Z1 P1 P2 P3
5 P4 P2 Z1 P3 T2
6 Z2 P3 P3 P1 T1 P3

输出样例:

No
No
Yes
Yes

先存下来每道菜所需要的用时
用scanf输入起止时间
算出来总时间T
对于每次询问
算出来做这些菜需要的时间t是否小于等于T、是否满足主菜、配菜、汤都有,可以用set维护。
似乎唯一要注意的点就是cin和scanf混用,别关同步流

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    int n1, n2, n3;
    std::cin >> n1 >> n2 >> n3;
    std::vector<int> a(n1), b(n2), c(n3);
    for (int i = 0; i < n1; i ++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n2; i ++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n3; i ++) {
        std::cin >> c[i];
    }
    int hh1, mm1, hh2, mm2;
    scanf("%d:%d", &hh1, &mm1);
    scanf("%d:%d", &hh2, &mm2);
    int q;
    std::cin >> q;
    int time = (hh2 * 60 + mm2) - (hh1 * 60 + mm1);
    while (q --) {
        auto calc = [&](std::string s) -> int {
            int x = 0;
            for (auto c : s) {
                x = (x * 10 + c - '0');
            }
            return x - 1;
        };
        int m;
        std::cin >> m;
        int sum = 0;
        std::set<char> cnt;
        for (int i = 0; i < m; i ++) {
            std::string s;
            std::cin >> s;
            int x = calc(s.substr(1));
            if (s[0] == 'Z') {
                sum += a[x];
            }
            if (s[0] == 'P') {
                sum += b[x];
            }
            if (s[0] == 'T') {
                sum += c[x];
            }
            cnt.insert(s[0]);
        }
        if (sum > time || cnt.size() != 3) {
            std::cout << "No\n";
        }
        else {
            std::cout << "Yes\n";
        }
    }
}
int main()
{
    // std::cin.tie(nullptr);
    // std::cout.tie(nullptr);
    // std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T6

输入样例:

5 3
500 200 800 30 180
15 0 35 2 20 35
180 0 10 80 67 50
88 0 0 28 10 0
1 0 1 1 5 1
100 0 57 80 100 77

输出样例:

467
73*
730
25
80*


统计一下每种书借出的数量,取max,剩下的总数,直接计算即可
输出每个书剩下的数量,然后判断这个书借出的数量是否与max相等

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    int n, d;
    std::cin >> n >> d;
    std::vector<int> a(n);
    std::vector<int> cnt(n);
    for (int i = 0; i < n; i ++) {
        std::cin >> a[i];
    }
    int max = 0;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < d; j ++) {
            int x, y;
            std::cin >> x >> y;
            cnt[i] += x;
            a[i] = a[i] - x + y;
        }
        max = std::max(max, cnt[i]);
    }
    for (int i = 0; i < n; i ++) {
        std::cout << a[i];
        if (cnt[i] == max) {
            std::cout << "*\n";
        }
        else {
            std::cout << '\n';
        }
    }
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}

T7

输入样例:

3
RH0ABP1
RH0APY
BPYORH0
9
BPYORH1
RH0ABP2
RH0APY
APYORH0
RH0OPY
BPYORH0
RH1APY
RH0APY
ABPYRH0

输出样例:

001001010
33.33
RH0APY

用set维护哪些血是熊猫血,用map维护每种熊猫血的查询次数
按要求输出答案即可

点击查看代码
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define lowbit(x) (x) & (-x)
using i64 = long long;
using pii = std::pair<int, int>;
void solve()
{
    int n;
    std::cin >> n;
    std::map<std::string, int> mp;
    std::set<std::string> st;
    for (int i = 0; i < n; i ++) {
        std::string s;
        std::cin >> s;
        st.insert(s);
    }
    int max = 0;
    int q;
    std::cin >> q;
    std::string ans;
    while (q --) {
        std::string s;
        std::cin >> s;
        if (st.count(s)) {
            ans.push_back('1');
            mp[s] ++;
            max = std::max(max, mp[s]);
        }
        else {
            ans.push_back('0');
        }
    }
    std::cout << ans << '\n';
    std::cout << std::fixed << std::setprecision(2) << 100.0 * std::count(all(ans), '1') / ans.size() << '\n';
    for (auto [s, cnt] : mp) {
        if (cnt == max) {
            std::cout << s << '\n';
        }
    }
}
int main()
{
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int T = 1;
    //std::cin >> T;
    while (T --) solve();
    return 0;
}
posted @ 2024-07-20 01:48  KXDdesu  阅读(96)  评论(0编辑  收藏  举报