https://atcoder.jp/contests/abc126/tasks/abc126_b
解説
https://atcoder.jp/contests/abc126/submissions/5475422
上2つを数値にしたものをa, 下2つを数値にしたものをbとする。
この変換は数字-'0'をすると、文字を数値化できることを利用する。
あとは、YYMMフォーマットかどうか、MMYYフォーマットかどうかを
チェックして、それを使って出力を分ければいい。
string S; //--------------------------------------------------------------------------------------------------- void _main() { cin >> S; int a = (S[0] - '0') * 10 + S[1] - '0'; int b = (S[2] - '0') * 10 + S[3] - '0'; bool YYMM = false; if (1 <= b and b <= 12) YYMM = true; bool MMYY = false; if (1 <= a and a <= 12) MMYY = true; if (YYMM and MMYY) cout << "AMBIGUOUS" << endl; else if (YYMM) cout << "YYMM" << endl; else if (MMYY) cout << "MMYY" << endl; else cout << "NA" << endl; }