よじろめ覚書

私の理解度重視のソースコードです。

ABC104B - AcCepted

問題:B - AcCepted

#include <iostream>
#include <string>
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
 
bool getJudge(string s) {
    int cnt = 0;
    
    if (s[0] != 'A') {
        return false;
    }
    
    FOR(i, 1, s.length()) {
        if (s[i] == 'C' && (i < 2 || s.length() - 2 < i)) {
            return false;
        }
        if (s[i] == 'C') {
            cnt++;
            continue;
        }
        if ('A' <= s[i] && s[i] <= 'Z') {
            return false;
        }
    }
    if (cnt != 1) {
        return false;
    }
    
    return true;
}
 
int main(void) {
    string s;
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << (getJudge(s)? "AC" : "WA") << "\n";
    return 0;
}

初回、'A'の考慮が完全に出来ていなかった為、3WA。。