题解:P11019 「LAOI-6」[太阳]] 请使用最新版手机 QQ 体验新功能

· · 题解

根据题面描述,输入的格式为 [AaaBbbCcc......]]QingShiYongZuiXinBanShouJiQQTiYanXinGongNeng

也就是说,拼音的音序一定是在 []] 之间的大写字母,我们只要找[(而[一定是第 1 个字符)和]]之间的大写字母就行了

时间复杂度 \le O(n)

代码:

#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl '\n'
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
string s;
int w;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>s;
    w=s.find(']');
    cout<<'/';
    for(int i=1;i<=w;i++){
        if(s[i]>='A'&&s[i]<='Z'){
            cout<<char(s[i]-'A'+'a');
        }
    }
    return 0;
}

AC!