よじろめ覚書

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

ABC109B - Shiritori

問題:B - Shiritori

#include <iostream>
#include <set>
#include <vector>
using namespace std;

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

int main(void){
    int n;
    vector<string> v_w(100);
    set<string> s_w;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> v_w[i];
        if (s_w.count(v_w[i]) > 0) {
            flg = false;
        }
        
        s_w.insert(v_w[i]);
    }
    REP (i, n - 1) {
        if (v_w[i].back() != v_w[i + 1].front()) {
            flg = false;
            break;
        }
    }
    
    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}