// No.239 にゃんぱすー // https://yukicoder.me/problems/no/239 // #include #include #include using namespace std; int solve(vector>& greetings, int N); int main() { int N; cin >> N; vector> greetings; greetings.resize(N); for (auto y = 0; y < N; y++) { greetings[y].resize(N); for (auto x = 0; x < N; x++) { cin >> greetings[y][x]; } } int ans = solve(greetings, N); cout << ans << endl; } int solve(vector>& greetings, int N) { vector candidates; for (auto y = 0; y < N; y++) { for (auto x = 0; x < N; x++) { if (greetings[y][x] == "nyanpass") greetings[x][y] = "nyanpass"; } } for (auto y = 0; y < N; y++) { int c = 0; for (auto j: greetings[y]) { if (j == "nyanpass") c++; } if (c == (N - 1)) candidates.push_back(y+1); } if (candidates.size() == 1) return candidates[0]; else return -1; }