結果

問題 No.239 にゃんぱすー
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 16:44:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 2,938 ms
コンパイル使用メモリ 77,548 KB
実行使用メモリ 58,652 KB
最終ジャッジ日時 2024-04-27 15:35:48
合計ジャッジ時間 9,999 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
54,264 KB
testcase_01 AC 98 ms
54,292 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 113 ms
54,080 KB
testcase_05 WA -
testcase_06 AC 116 ms
54,248 KB
testcase_07 AC 119 ms
54,220 KB
testcase_08 AC 122 ms
54,244 KB
testcase_09 WA -
testcase_10 AC 139 ms
54,356 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 158 ms
54,328 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 181 ms
56,332 KB
testcase_21 WA -
testcase_22 AC 180 ms
56,908 KB
testcase_23 AC 183 ms
56,876 KB
testcase_24 AC 199 ms
57,752 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 114 ms
53,552 KB
testcase_28 AC 140 ms
53,944 KB
testcase_29 WA -
testcase_30 AC 156 ms
53,628 KB
testcase_31 AC 156 ms
54,256 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 184 ms
58,328 KB
testcase_35 WA -
testcase_36 AC 242 ms
58,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String str = "nyanpass";
		String[][] s = new String[n][n];
		boolean[] b = new boolean[n];
		for(int i = 0; i < n; i++){
			b[i] = true;
		}
		for(int i= 0; i < n; i++){
			for(int j = 0; j < n; j++){
				s[i][j] = sc.next();
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j){
					continue;
				}
				if(b[j]){
					if(!s[i][j].equals(str)){
						b[j] = false;
					}
				}
			}
		}
		int ren = -1, cnt = n;
		for(int i = 0; i < n; i++){
			if(b[i]){
				ren = i;
			} else {
				cnt--;
			}
		}
		if(cnt > 1 || cnt == 0){
			System.out.println(-1);
		} else {
			System.out.println(ren);
		}
	}
}
0