#include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); class Pos{ public: int row; int col; Pos(int i, int j) : row(i), col(j) {} }; int n; std::cin >> n; std::vector> s(n, std::vector(n)); std::vector> evaluation(n, std::vector(n)); std::vector position; std::vector point(n, 0); int noBattleNum = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { char c; std::cin >> c; switch (c) { case '#': s[i][j] = 99; break; case 'o': s[i][j] = 1; break; case 'x': s[i][j] = -1; break; case '-': s[i][j] = 0; if (i < j) { ++noBattleNum; position.push_back(Pos(i, j)); } break; } } } int min = 10; for (int k = 0; k < std::pow(2, noBattleNum); ++k) { int tmp = k; evaluation = s; for (int i = 0; i < noBattleNum; ++i) { if (tmp % 2 == 1) { evaluation[position[i].col][position[i].row] = 1; evaluation[position[i].row][position[i].col] = -1; } else { evaluation[position[i].col][position[i].row] = -1; evaluation[position[i].row][position[i].col] = 1; } tmp /= 2; } for (int i = 0; i < n; ++i) { int sum = 0; for (int j = 0; j < n; ++j) { if (evaluation[i][j] == 99) continue; sum += evaluation[i][j]; } point[i] = sum; } int pointZero = point[0]; std::sort(point.begin(), point.end()); std::reverse(point.begin(), point.end()); std::vector rank; for (int i = 0; i < n; ++i) { if (std::find(rank.begin(), rank.end(), point[i]) == rank.end()) { rank.push_back(point[i]); } } for (int i = 0; i < rank.size(); ++i) { if (rank[i] == pointZero) { min = (min > i + 1) ? i + 1 : min; } } } std::cout << min << "\n"; return 0; }