結果

問題 No.239 にゃんぱすー
ユーザー YamaKasaYamaKasa
提出日時 2018-05-01 02:06:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 60,016 KB
最終ジャッジ日時 2023-09-10 08:35:13
合計ジャッジ時間 11,183 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,732 KB
testcase_01 AC 129 ms
55,788 KB
testcase_02 AC 129 ms
55,952 KB
testcase_03 AC 131 ms
55,480 KB
testcase_04 AC 128 ms
55,540 KB
testcase_05 AC 127 ms
55,804 KB
testcase_06 AC 127 ms
55,552 KB
testcase_07 AC 132 ms
55,844 KB
testcase_08 AC 136 ms
55,788 KB
testcase_09 AC 141 ms
55,580 KB
testcase_10 AC 173 ms
56,088 KB
testcase_11 AC 177 ms
56,352 KB
testcase_12 AC 178 ms
56,240 KB
testcase_13 AC 183 ms
56,188 KB
testcase_14 AC 182 ms
56,332 KB
testcase_15 AC 180 ms
56,396 KB
testcase_16 AC 185 ms
56,084 KB
testcase_17 AC 192 ms
58,012 KB
testcase_18 AC 198 ms
58,356 KB
testcase_19 AC 198 ms
58,268 KB
testcase_20 AC 198 ms
58,764 KB
testcase_21 AC 202 ms
58,528 KB
testcase_22 AC 206 ms
58,736 KB
testcase_23 AC 211 ms
59,216 KB
testcase_24 AC 218 ms
59,408 KB
testcase_25 AC 221 ms
59,632 KB
testcase_26 AC 227 ms
59,760 KB
testcase_27 AC 140 ms
55,672 KB
testcase_28 AC 171 ms
56,060 KB
testcase_29 AC 165 ms
56,312 KB
testcase_30 AC 179 ms
56,064 KB
testcase_31 AC 205 ms
55,596 KB
testcase_32 AC 195 ms
58,836 KB
testcase_33 AC 203 ms
58,728 KB
testcase_34 AC 205 ms
58,916 KB
testcase_35 AC 220 ms
59,400 KB
testcase_36 AC 227 ms
60,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		String temp = "";
		int [][] B = new int[N][N];

		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				temp = scan.next();
				if(temp.equals("nyanpass")) {
					B[i][j] = 1;
				}else {
					B[i][j] = 0;
				}
			}
		}
		scan.close();
		int []cnt = new int[N];
		Arrays.fill(cnt, 0);
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				if(B[j][i] == 1) {
					cnt[i] ++;
				}
			}
		}
		int k = 0;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(cnt[i] == N - 1) {
				ans = i + 1;
				k ++;
			}
		}
		if(k > 1 || k == 0) {
			System.out.println("-1");
		}else {
			System.out.println(ans);
		}


	}
}
0