よじろめ覚書

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

ABC003B - AtCoderトランプ

問題:B - AtCoderトランプ

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

#define REP(i, n) for(int i = 0; i < (n); ++i)

int main(void) {
    const string card = "atcoder";
    string s, t;
    bool flg = true;

    cin >> s >> t;
    if (s != t) {
        REP(i, min(s.length(), t.length())) {
            if (s[i] != t[i] && s[i] == '@' && card.find(t[i]) == string::npos) {
                flg = false;
                break;
            }
            if (s[i] != t[i] && t[i] == '@' && card.find(s[i]) == string::npos) {
                flg = false;
                break;
            }
            if (s[i] != t[i] && s[i] != '@' && t[i] != '@') {
                flg = false;
                break;
            }
        }
    }

    if (flg && s.length() == t.length()) {
        printf ("You can win\n");
    } else {
        printf ("You will lose\n");
    }
    return 0;
}