結果
問題 | No.239 にゃんぱすー |
ユーザー |
![]() |
提出日時 | 2017-02-07 10:50:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 166,232 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 09:58:11 |
合計ジャッジ時間 | 3,564 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; string s[n][n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> s[i][j]; } } int count = 0; map<int, int> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (s[i][j] == "nyanpass") { m[j]++; } } } int ans=0; for (int j = 0; j < n; ++j) { if (m[j] == n - 1 && count == 0) { count++; ans=j; } else if (m[j] == n - 1 && count == 1) { cout << -1 << endl; return 0; } } if (count == 1) { cout << ans + 1 << endl; } else { cout << -1 << endl; return 0; } }