結果

問題 No.239 にゃんぱすー
ユーザー hanorver
提出日時 2015-08-21 16:40:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 63,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 11:18:50
合計ジャッジ時間 1,592 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const std::string n = "nyanpass";

int main() {
	int people;

	std::cin >> people;

	std::vector<int> nyanpas_count(people, 0);
	for (int i = 0; i < people; i++) {
		for (int j = 0; j < people; j++) {
			std::string str;
			std::cin >> str;
			if (str == n){
				nyanpas_count[j]++;
			}
		}
	}

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

	return 0;
}
0