#include #include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector s(n), t(n); for (int i = 0; i < n; ++i) { cin >> s[i]; t[i] = s[i]; } int games = n * (n - 1) / 2; int patterns = 1 << games; int minOrder = numeric_limits::max(); for (int bits = 0x0; bits < patterns; ++bits) { int mask = 0x1; for (int y = 1; y < n; ++y) { for (int x = 0; x < y; ++x) { if (s[x][y] == '-') { bool win = (bits & mask); t[x][y] = win ? 'o' : 'x'; t[y][x] = win ? 'x' : 'o'; } mask <<= 1; } } set > scores; for (int i = 1; i < n; ++i) { scores.insert(count(t[i].begin(), t[i].end(), 'o')); } int score0 = count(t[0].begin(), t[0].end(), 'o'); int order = 1; for (set::const_iterator it = scores.begin(); it != scores.end() && score0 < *it; ++it, ++order) { } minOrder = min(minOrder, order); } cout << minOrder << endl; return 0; }