#include #include using namespace std; using namespace atcoder; #define rep(i, n) REP(i, 0, n) #define REP(i, s, e) for (ll i = (s); i < (ll)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for (ll i = (ll)(s - 1); i >= (ll)(e); i--) #define all(r) r.begin(), r.end() #define rall(r) r.rbegin(), r.rend() typedef long long ll; typedef vector vi; typedef vector vl; template bool chmax(T& a, const U& b) { if (a >= b) return false; a = b; return true; } template bool chmin(T& a, const U& b) { if (a <= b) return false; a = b; return true; } void yes_no(bool f, string yes = "Yes", string no = "No") { cout << (f ? yes : no) << "\n"; } void solve() { int n; cin >> n; vector s(n); rep(i, n) cin >> s[i]; rep(i, n) if (s[0][i] == '-') { s[0][i] = 'o'; s[i][0] = 'x'; } using P = pair; vector

vs; rep(i, n) rep(j, i) if (s[i][j] == '-') { vs.emplace_back(i, j); } int ans = 1e9; int m = vs.size(); rep(mask, 1 << m) { rep(i, m) { s[vs[i].first][vs[i].second] = (mask & (1 << i)) ? 'o' : 'x'; s[vs[i].second][vs[i].first] = (mask & (1 << i)) ? 'x' : 'o'; } vector win(n); rep(i, n) { int cnt = 0; rep(j, n) if (s[i][j] == 'o') cnt++; win[cnt].emplace_back(i); } int cnt = 0; repr(i, n) { if (win[i].empty()) continue; cnt++; rep(j, win[i].size()) if (win[i][j] == 0) chmin(ans, cnt); } } cout << ans << "\n"; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t = 1; // cin >> t; rep(ti, t) solve(); return 0; }