#include #include #include using namespace std; int main(){ int n;cin>>n; vector> A(n,vector(n)); vector> T(n,vector(n,'.')); for(int i = 0; n > i; i++){ for(int j = 0; n > j; j++){ cin>>A[i][j]; } } int ret = n+1; for(int i = 0; (1<<(n*(n-1)/2)) > i; i++){ bool ok = true; for(int j = 0; (n*(n-1)/2) > j; j++){ //n-1, n-2, ..., 1 int nw = j+1; int v = 0; for(int k = n-1; 1 <= k; k--){ nw -= k; if(nw <= 0){ nw+=k; break; } v++; } char x = ((i & (1<> Z; // for(int j = 0; n > j; j++){ // for(int k = 0; n > k; k++){ // cout << T[j][k] << " "; // } // cout << endl; // } for(int j = 0; n > j; j++){ int win = 0; for(int k = 0; n > k; k++){ if(j==k)continue; if(T[j][k] == 'o')win++; } Z.push_back({j,win}); } sort(Z.begin(),Z.end(),[&](pair a, pair b){return a.second > b.second;}); // for(int j = 0; n > j; j++){ // cout << Z[j].first << " " << Z[j].second << endl; // } int rank = 1; for(int j = 0; n > j; j++){ if(j && Z[j-1].second != Z[j].second){ rank++; } if(Z[j].first == 0){ ret = min(ret,rank); } } } cout << ret << endl; }