2021 RoboCom 世界机器人开发者大赛-高职组(初赛)

机器人打招呼

签到

print("ni ye lai can jia RoboCom a?")

人脸识别

签到

#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    int a , b , c ;
    int x , y , z;
    int t;
    cin >> a >> b >> c >> t >> x >> y >> z;
    cout << "Diff = " << a - x << ", "<< b - y << ", " << c - z <<"\n";
    if( abs(a - x) + abs(b - y)  + abs(c - z) <= t )
        cout <<"Yes\n";
    else
        cout << "No\n";
    return 0;
}

月份输出

签到

#include<bits/stdc++.h>
#define int long long
using namespace std;

int read() {
    int x = 0, f = 1, ch = getchar();
    while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
    if (ch == '-') f = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * f;
}

 string s[] = { "" , "January\n","February\n","March\n","April\n",
                "May\n","June\n","July\n","August\n",
                "September\n","October\n","November\n","December\n"};

int32_t main() {
    int x;
    while( 1 )
    {
        x = read();
        if( x < 1 || x > 12 )
            printf("?\n") , exit(0);
        cout << s[x];
    }
    return 0;
}

字母串

逐个字符判断就好

#include<bits/stdc++.h>

using namespace std;

string s;

void solve(){
    cin >> s;
    for( int i = 0 ; i + 1 < s.size() ; i ++ )
    {
        if( s[i] >= 'a' && s[i] <= 'z' )
        {
            if( s[i+1] != s[i] - 'a' + 'A' && s[i+1] != s[i]-1 )
            {
                printf("N\n");
                return;
            }
        }
        else
        {
            if( s[i+1] != s[i] - 'A' + 'a' && s[i+1] != s[i]+1 )
            {
                printf("N\n");
                return;
            }
        }
    }
    printf("Y\n");
}

int32_t main() {
    int t ; cin >> t;
    while( t -- )
        solve();
    return 0;
}

增一数

这题的坑点在于有前导零

#include<bits/stdc++.h>
#define int long long
using namespace std;


void solve(){
    int x , k = 0;
    cin >> x ;
    int xx = x;
    while( xx )
        xx /= 10 , k ++;
    if( k % 2 )
    {
        cout << "0\n";
        return;
    }
    k = pow(10 , k / 2 );
    if( x % k - 1 == x / k ){
        if (ceil(sqrt(x)) * ceil(sqrt(x)) == x)
            cout << "2\n";
        else
            cout <<"1\n";
        return;
    }
    else {
        cout <<"0\n";
        return;
    }
}

int32_t main() {
    int t ; cin >> t;
    while( t -- )
        solve();
    return 0;
}

答题卡

#include<iostream>
#include<cstring>
#include<sstream>
#include<string>
using namespace std;
char mg[100][100];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        string str;
        cin>>str;
        stringstream ss;
        ss<<str;
        int a,b;
        char c;
        ss>>a;
        if(ss.rdbuf()->in_avail()==0)
        {
            mg[a/100][a%100]='#';
            continue;
        }
        ss>>c>>b;
        mg[a][b]='#';
    }
    for(int i=n;i>=1;i--)
    {
        for(int j=1;j<=n;j++)
            if(mg[j][i]!='#')
                cout<<'.';
            else
                cout<<'#';
        cout<<endl;
    }
    return 0;
}

救救倒霉鬼

直接全部丢到 map 就好了

#include<bits/stdc++.h>

using namespace std;

string s;
int n , m;
map< string , bool > st;
vector< string > res;

int32_t main() {
    cin >> n;
    for( ; n ; n -- ){
        cin >> s;
        st[s] = 1;
    }
    cin >> m;
    for( ; m ; m -- ){
        cin >> s;
        st[s] = 0;
    }
    for( auto [ k , v ] : st )
        if( v ) res.push_back( k );
    reverse( res.begin() , res.end() );
    for( auto it : res )
        cout << it << "\n";
    return 0;
}
posted @ 2022-07-07 09:32  PHarr  阅读(169)  评论(0编辑  收藏  举报