#include #include #include #include #include void solve() { int n; std::cin >> n; std::vector win(n, 0); std::vector> ps; for (int x = 0; x < n; ++x) { for (int y = 0; y < n; ++y) { char c; std::cin >> c; if (x >= y) continue; if (c == 'o') { ++win[x]; } else if (c == 'x') { ++win[y]; } else if (c == '-') { ps.emplace_back(x, y); } } } int m = ps.size(); int ans = n; for (int b = 0; b < (1 << m); ++b) { auto nwin = win; for (int i = 0; i < m; ++i) { int x, y; std::tie(x, y) = ps[i]; if ((b >> i) & 1) { ++nwin[x]; } else { ++nwin[y]; } } std::set up; for (int x = 1; x < n; ++x) { if (nwin[x] > nwin[0]) { up.insert(nwin[x]); } } ans = std::min(ans, (int)up.size() + 1); } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }