結果

問題 No.239 にゃんぱすー
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-30 18:37:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,374 bytes
コンパイル時間 2,880 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 53,856 KB
最終ジャッジ日時 2023-10-11 23:54:00
合計ジャッジ時間 6,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
47,360 KB
testcase_01 AC 44 ms
49,316 KB
testcase_02 AC 44 ms
49,212 KB
testcase_03 AC 44 ms
47,576 KB
testcase_04 AC 45 ms
49,412 KB
testcase_05 AC 44 ms
49,516 KB
testcase_06 AC 44 ms
49,240 KB
testcase_07 AC 44 ms
49,656 KB
testcase_08 AC 45 ms
49,384 KB
testcase_09 AC 45 ms
49,252 KB
testcase_10 AC 45 ms
49,088 KB
testcase_11 AC 47 ms
49,272 KB
testcase_12 AC 52 ms
49,488 KB
testcase_13 AC 52 ms
49,748 KB
testcase_14 AC 53 ms
49,396 KB
testcase_15 AC 54 ms
49,260 KB
testcase_16 AC 55 ms
49,320 KB
testcase_17 AC 58 ms
50,416 KB
testcase_18 AC 63 ms
50,952 KB
testcase_19 AC 66 ms
50,348 KB
testcase_20 AC 71 ms
51,408 KB
testcase_21 AC 76 ms
50,776 KB
testcase_22 AC 88 ms
51,120 KB
testcase_23 AC 79 ms
51,092 KB
testcase_24 AC 93 ms
51,256 KB
testcase_25 AC 93 ms
51,656 KB
testcase_26 AC 95 ms
51,692 KB
testcase_27 AC 45 ms
49,404 KB
testcase_28 AC 46 ms
49,316 KB
testcase_29 AC 51 ms
49,484 KB
testcase_30 AC 54 ms
49,352 KB
testcase_31 AC 57 ms
50,436 KB
testcase_32 AC 61 ms
50,324 KB
testcase_33 AC 73 ms
50,456 KB
testcase_34 AC 89 ms
51,488 KB
testcase_35 AC 94 ms
51,112 KB
testcase_36 AC 100 ms
53,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.System.in;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        String[] inputs;
        int[][] table = new int[N][N];
        for (int i = 0; i < N; i++) {
            inputs = reader.readLine().split(" ");
            for (int j = 0; j < N; j++) {
                if (inputs[j].equals("nyanpass")) {
                    table[i][j] += 1;
                }
            }
        }

        int[] villagers = new int[N];
        for (int i = 0; i < N; i++) {
            int counter = 0;
            for (int j = 0; j < N; j++) {
                if (table[j][i] == 1) {
                    counter += 1;
                }
            }
            villagers[i] = counter;
        }


        int possibleNum = 0;
        int villagerId = -1;
        for (int i = 0; i < N; i++) {
            if (villagers[i] == N - 1) {
                possibleNum += 1;
                villagerId = i+1;
            }
        }
        if(possibleNum==1){
            System.out.println(villagerId);
        } else {
            System.out.println(-1);
        }

    }
}
0