結果

問題 No.239 にゃんぱすー
ユーザー @abcde
提出日時 2019-02-10 17:31:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 165,216 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 13:58:26
合計ジャッジ時間 2,632 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    
    // 1. 入力情報取得.
    int N;
    cin >> N;
    map<int, int> m;
    for(int i = 1; i < N + 1; i++){
        for(int j = 1; j < N + 1; j++){
            // 村民j番 の "nyanpass"発言回数 を保管.
            string a;
            cin >> a;
            if(a == "nyanpass") m[j]++;
        }
    }
    
    // 2. "れんちょんっぽい"村民を探索.
    int ans = -1;
    int isOne = true;
    for(auto &p : m){
        if(p.second == N - 1 && !isOne){
            ans = -1;
            break;
        }
        if(p.second == N - 1 && isOne) ans = p.first, isOne = false;
    }
    
    // 3. 出力 ~ 後処理.
    cout << ans << endl;
    return 0;
    
}
0