結果

問題 No.239 にゃんぱすー
ユーザー hanorver
提出日時 2015-11-06 09:47:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 63,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 12:59:55
合計ジャッジ時間 1,708 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

int main(){
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for (size_t i = 0; i < n; i++) {
        for (size_t j = 0; j < n; j++) {
            std::string greet;
            std::cin >> greet;
            if(greet == "nyanpass") v[j]++;
        }
    }

    int max = *std::max_element(v.begin(), v.end());
    if(max != n - 1 || std::count(v.begin(), v.end(), max) != 1){
        std::cout << -1 << std::endl;
        return 0;
    }
    for (size_t i = 0; i < v.size(); i++) {
        if(v[i] == max){
            std::cout << i + 1 << std::endl;
            return 0;
        }
    }
    return 0;
}
0