CF 1820A-Yura's New Name, 800 / 思维 / ^-^ 或 ^^ 才合法

发布时间 2023-04-19 20:42:03作者: 妃即

CF 1820A-Yura's New Name

处理方式 :
特殊情况提前判断 + 一般情况从首推到尾

#include <iostream>
#include <cstring>

using namespace std;

const int N = 1e2 + 10;
typedef long long LL;

int T;
string s;
int main()
{
    cin >> T;
    while (T -- )
    {
        cin >> s;
        s = '_' + s + '_';
        
        if (s.size() == 3 && s[1] == '^')
        {
            cout << 1 << '\n';
            continue;
        }
        
        int a = 0;
        for (int i = 1; i < s.size(); i ++ )
        {
            if (s[i] != '^' && s[i - 1] != '^') a ++ ;
        }
        
        cout << a << '\n';
    }
        
       
    
    return 0;
}