#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; vector S(N); FOR(i, 0, N){ cin >> S.at(i); } ll rank = inf; // N==6の場合でも全ての表の埋め方は2^15通り FOR(mask, 0, 1<<15){ ll k = -1; map mp; // 表の右上半分のみを見る FOR(i, 0, N){ FOR(j, i+1, N){ k++; if(S[i][j]=='-'){ if(mask>>k & 1){ mp[i]++; }else{ mp[j]++; } } else if(S[i][j]=='o'){ mp[i]++; } else{ mp[j]++; } } } // 結果集計 set se; FOR(i, 0, N){ ll win = mp[i]; se.insert(win); } ll player_win = mp[0]; ll dist = distance(se.begin(), se.lower_bound(player_win)); ll order = se.size() - dist; chmin(rank, order); } p(rank); return 0; }