よじろめ覚書

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

ABC084B - Postal Code

問題:B - Postal Code

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

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

int main(void) {
    int a, b;
    string s;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    cin >> s;
    REP(i, a) {
        if (s[i] < '0' || '9' < s[i]) {
            flg = false;
        }
    }
    if (flg && s[a] != '-') {
        flg = false;
    }
    if (flg) {
        FOR(i, a + 1, s.length()) {
            if (s[i] < '0' || '9' < s[i]) {
               flg = false;
            }
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}