結果

問題 No.239 にゃんぱすー
ユーザー koukonko
提出日時 2015-12-19 17:34:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 73,820 KB
実行使用メモリ 39,460 KB
最終ジャッジ日時 2024-09-16 16:08:50
合計ジャッジ時間 6,091 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(read.readLine());
			int[] count = new int[N];

			for (int i = 0; i < N; ++i) {
				String[] box = read.readLine().split(" ");

				for (int j = 0; j < N; ++j) {
					if (box[j].equals("nyanpass")) {
						count[j]++;
					}
				}
			}

			int ans = -1;
			for (int i = 0; i < N; ++i) {
				if (count[i] == N - 1) {
					if (ans == -1) {
						ans = i + 1;
					} else {
						ans = -1;
						break;
					}
				}
			}

			System.out.println(ans);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
0