题解:P14124 [SCCPC 2021] Nihongo wa Muzukashii Desu

· · 题解

签到题。按题意进行模拟即可。

赛时AC代码如下


#include<bits/stdc++.h>

using namespace std;

const int Maxn = 1e6 + 5;

vector<pair<string, string>> strmd = {
    {"shimasu","shite"},{"chimasu","tte"},{"rimasu","tte"},
    {"mimasu","nde"},{"bimasu","nde"},{"nimasu","nde"},
    {"kimasu","ite"},{"gimasu","ide"},{"imasu","tte"} };


int main(){
    int T;  cin >> T;
    while(T --){
        string str;
        cin >> str;
        if(str == "ikimasu"){
            cout << "itte" << '\n';
            continue;
        }

        for(auto s : strmd){
            int tmp = str.length() - s.first.length();
            if(tmp <= 0) continue;
            if(str.substr(tmp) == s.first){
                cout << str.substr(0, str.length() - s.first.length()) + s.second << '\n';
                break;
            }
        }
    }
    return 0;
}