結果

問題 No.548 国士無双
ユーザー samplelpmassamplelpmas
提出日時 2017-07-31 03:51:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 4,558 ms
コンパイル使用メモリ 76,992 KB
実行使用メモリ 57,544 KB
最終ジャッジ日時 2023-10-17 16:04:08
合計ジャッジ時間 6,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
57,128 KB
testcase_01 AC 140 ms
57,112 KB
testcase_02 AC 138 ms
57,188 KB
testcase_03 AC 106 ms
57,360 KB
testcase_04 AC 109 ms
57,156 KB
testcase_05 AC 104 ms
56,312 KB
testcase_06 AC 108 ms
57,456 KB
testcase_07 AC 116 ms
57,532 KB
testcase_08 AC 141 ms
56,296 KB
testcase_09 AC 116 ms
56,312 KB
testcase_10 AC 103 ms
56,248 KB
testcase_11 AC 110 ms
57,344 KB
testcase_12 AC 107 ms
57,384 KB
testcase_13 AC 109 ms
57,336 KB
testcase_14 AC 128 ms
57,260 KB
testcase_15 AC 148 ms
57,140 KB
testcase_16 AC 141 ms
57,468 KB
testcase_17 AC 110 ms
57,256 KB
testcase_18 AC 110 ms
57,224 KB
testcase_19 AC 116 ms
57,404 KB
testcase_20 AC 118 ms
57,264 KB
testcase_21 AC 114 ms
57,544 KB
testcase_22 AC 115 ms
57,284 KB
testcase_23 AC 110 ms
57,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        char[] S = sc.next().toCharArray();

        int[] alphabetCount = new int[13];

        for (int i = 0; i < S.length; i++) {

            if (S[i] - 'a' >= 13) {
                System.out.println("Impossible");
                return;
            }

            alphabetCount[S[i] - 'a']++;

        }

        int zeroCount = 0;

        for (int i = 0; i < S.length; i++) {

            if (alphabetCount[i] == 0) {
                zeroCount++;
            }

        }

        if (zeroCount == 0) {

            for (int i = 0; i < S.length; i++) {
                System.out.println((char) (i + 'a'));
            }

        } else if (zeroCount == 1) {

            for (int i = 0; i < S.length; i++) {

                if (alphabetCount[i] == 0) {
                    System.out.println((char) (i + 'a'));
                }

            }

        } else if (zeroCount >= 2) {

            System.out.println("Impossible");

        }

    }

}
0