2 条题解

  • 1
    @ 2024-3-10 15:34:53

    答案 `

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int money[50100];
    int main(){
        int t;
        cin >>t;
        for (int i = 0;i<t;i++){
            int n;
            string l;
            cin >>n>>l;
            int wg = 0;
            int rmb = 0;
            for (int j = 0;;j++){
                if (wg >= n - 1){
                    money[i] = rmb;
                    break;
                }
                if(l[wg + 1] == '.'){
                    if (wg + 1 >= n){
                        money[i] = rmb;
                        break;
                    }
                    wg++;
                }
                if(l[wg + 1] == '@'){
                    if (wg + 1 >= n){
                        money[i] = rmb;
                        break;
                    }
                    wg++;
                    rmb++;
                }
                else if(l[wg + 1] == '*' && wg + 2 >= l.size()){
                    money[i] = rmb;
                    break;
                }
                else if(l[wg + 1] == '*' && l[wg + 2] == '.'){
                    if (wg + 2 >= n){
                        money[i] = rmb;
                        break;
                    }
                    wg += 2;
                }
                else if(l[wg + 1] == '*' && l[wg + 2] == '@'){
                    if (wg + 2 >= n){
                        money[i] = rmb;
                        break;
                    }
                    wg += 2;
                    rmb++;
                }
                else if(l[wg + 1] == '*' && l[wg + 2] == '*'){
                    money[i] = rmb;
                    break;
                }
            }
        }
        for (int i = 0;i<t;i++){
            cout <<money[i]<<endl;
        }
    }
    

    信息

    ID
    715
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    (无)
    递交数
    65
    已通过
    21
    上传者