結果

問題 No.239 にゃんぱすー
ユーザー yagi2yagi2
提出日時 2017-04-20 16:30:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 2,498 ms
コンパイル使用メモリ 79,980 KB
実行使用メモリ 59,908 KB
最終ジャッジ日時 2023-09-27 03:43:37
合計ジャッジ時間 9,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 107 ms
55,580 KB
testcase_03 AC 111 ms
56,228 KB
testcase_04 AC 110 ms
55,844 KB
testcase_05 AC 109 ms
56,004 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 115 ms
56,404 KB
testcase_09 AC 122 ms
56,336 KB
testcase_10 AC 148 ms
56,136 KB
testcase_11 AC 146 ms
56,212 KB
testcase_12 AC 146 ms
56,460 KB
testcase_13 AC 157 ms
56,112 KB
testcase_14 AC 156 ms
56,360 KB
testcase_15 AC 155 ms
56,088 KB
testcase_16 AC 147 ms
56,612 KB
testcase_17 AC 156 ms
58,928 KB
testcase_18 AC 167 ms
58,232 KB
testcase_19 AC 175 ms
58,264 KB
testcase_20 AC 181 ms
58,712 KB
testcase_21 AC 190 ms
58,516 KB
testcase_22 AC 184 ms
58,496 KB
testcase_23 AC 189 ms
58,840 KB
testcase_24 AC 199 ms
59,464 KB
testcase_25 AC 196 ms
59,544 KB
testcase_26 AC 208 ms
59,908 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 149 ms
56,140 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 176 ms
58,612 KB
testcase_33 AC 179 ms
58,776 KB
testcase_34 WA -
testcase_35 AC 195 ms
59,524 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        Map<Integer, Integer> renchon = new HashMap<>();

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                String s = sc.next();
                if (s.equals("nyanpass")) {
                    if (!renchon.containsKey(j)) {
                        renchon.put(j, 0);
                    }
                    renchon.put(j, renchon.get(j)+1);
                }
            }
        }

        int renchonNum = -1;
        boolean renchonFlag = false;
        for (int i = 0; i < N; i++) {
            if (!renchon.containsKey(i)) continue;
            if (renchon.get(i) == N - 1 && renchonNum == -1) {
                renchonNum = i;
                continue;
            }
            if (renchon.get(i) == N - 1 && renchonNum != 1) {
                renchonFlag = true;
            }
        }

        if (!renchonFlag) {
            System.out.println(renchonNum+1);
        } else {
            System.out.println("-1");
        }
    }
}
0