#include #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; int main() { int N; cin >> N; vector> s(N, vector(N, 0)); vector yet; for (ll i = 0; i < N; i++) { for (ll j = 0; j < N; j++) { char c; cin >> c; if (c == 'o') { s[i][j] = 1; s[j][i] = -1; } else if (c == 'x') { s[i][j] = -1; s[j][i] = 1; } else if (c == '-') { s[i][j] = 0; if (i < j) { yet.push_back(make_pair(i, j)); } } } } const int maximum = 1 << (yet.size()); int mini = 1000000; for (int i = 0; i < maximum; i++) { int num = i; for (int j = 0; j < yet.size(); j++) { const bool b = num % 2; const int I = yet[j].first; const int J = yet[j].second; if (b) { s[I][J] = 1; s[J][I] = -1; } else { s[J][I] = 1; s[I][J] = -1; } num /= 2; } vector scores(N + 1, 0); int s0 = 0; for (int a = 0; a < N; a++) { int n = 0; for (int b = 0; b < N; b++) { if (s[a][b] == 1) { n++; } } if (a == 0) { s0 = n; } scores[n]++; } int ans = 0; for (int g = N; g >= s0; g--) { if (scores[g] > 0) { ans++; } } mini = min(ans, mini); } cout << mini << endl; return 0; }