結果

問題 No.239 にゃんぱすー
ユーザー tentententen
提出日時 2020-11-11 08:59:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 72,112 KB
実行使用メモリ 59,656 KB
最終ジャッジ日時 2023-09-30 00:22:13
合計ジャッジ時間 10,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,816 KB
testcase_01 AC 116 ms
55,840 KB
testcase_02 AC 115 ms
55,376 KB
testcase_03 AC 118 ms
55,352 KB
testcase_04 AC 117 ms
55,368 KB
testcase_05 AC 116 ms
57,640 KB
testcase_06 AC 116 ms
55,940 KB
testcase_07 AC 119 ms
55,528 KB
testcase_08 AC 123 ms
55,580 KB
testcase_09 AC 128 ms
56,108 KB
testcase_10 AC 157 ms
56,136 KB
testcase_11 AC 160 ms
56,368 KB
testcase_12 AC 162 ms
56,184 KB
testcase_13 AC 167 ms
56,064 KB
testcase_14 AC 157 ms
56,412 KB
testcase_15 AC 169 ms
56,352 KB
testcase_16 AC 175 ms
56,428 KB
testcase_17 AC 176 ms
58,588 KB
testcase_18 AC 179 ms
58,360 KB
testcase_19 AC 181 ms
58,120 KB
testcase_20 AC 189 ms
58,316 KB
testcase_21 AC 190 ms
58,288 KB
testcase_22 AC 200 ms
59,292 KB
testcase_23 AC 210 ms
58,880 KB
testcase_24 AC 201 ms
59,212 KB
testcase_25 AC 205 ms
59,256 KB
testcase_26 AC 210 ms
59,444 KB
testcase_27 AC 123 ms
55,924 KB
testcase_28 AC 155 ms
56,628 KB
testcase_29 AC 162 ms
56,360 KB
testcase_30 AC 165 ms
57,028 KB
testcase_31 AC 174 ms
56,524 KB
testcase_32 AC 189 ms
58,444 KB
testcase_33 AC 187 ms
58,372 KB
testcase_34 AC 191 ms
59,136 KB
testcase_35 AC 201 ms
59,448 KB
testcase_36 AC 211 ms
59,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[][] probables = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                probables[i][j] = (sc.next().equals("nyanpass"));
            }
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            boolean flag = true;
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                flag &= probables[j][i];
            }
            if (flag) {
                list.add(i + 1);
            }
        }
        if (list.size() == 1) {
            System.out.println(list.get(0));
        } else {
            System.out.println(-1);
        }
    }
}
0