結果

問題 No.548 国士無双
ユーザー OlderInvestorOlderInvestor
提出日時 2017-10-29 19:57:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 3,496 ms
コンパイル使用メモリ 75,460 KB
実行使用メモリ 57,548 KB
最終ジャッジ日時 2023-10-17 16:24:08
合計ジャッジ時間 7,283 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
57,444 KB
testcase_01 AC 121 ms
57,480 KB
testcase_02 AC 120 ms
57,468 KB
testcase_03 AC 121 ms
57,364 KB
testcase_04 AC 122 ms
57,212 KB
testcase_05 AC 120 ms
57,468 KB
testcase_06 AC 112 ms
56,212 KB
testcase_07 AC 109 ms
56,212 KB
testcase_08 AC 122 ms
57,452 KB
testcase_09 AC 119 ms
57,548 KB
testcase_10 AC 122 ms
57,548 KB
testcase_11 AC 120 ms
57,448 KB
testcase_12 AC 123 ms
57,436 KB
testcase_13 AC 124 ms
57,448 KB
testcase_14 AC 124 ms
57,464 KB
testcase_15 AC 120 ms
57,456 KB
testcase_16 AC 122 ms
57,304 KB
testcase_17 AC 119 ms
57,492 KB
testcase_18 AC 120 ms
57,440 KB
testcase_19 AC 128 ms
57,444 KB
testcase_20 AC 124 ms
57,532 KB
testcase_21 AC 109 ms
56,212 KB
testcase_22 AC 126 ms
56,208 KB
testcase_23 AC 121 ms
57,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Arrays;
import java.util.Scanner;

public class No548 {
    public static void main(String[] args) {
        String s = new Scanner(System.in).next();
        char[] schar = s.toCharArray();
        char[] charCnt = new char[13];
        int zeroCnt = 0;
        char onlyOne = 0;

        Arrays.sort(schar);
        for(int i = 0; i < 13; i++) {
            if(schar[i] - 97 < 13) {
                charCnt[schar[i] - 97] += 1;
            }
        }

        for(int i = 0; i < 13; i++) {
            if(charCnt[i] == 0) {
                zeroCnt++;
                onlyOne = (char)(i + 97);
            }
        }

        if(zeroCnt == 0) {
            for(int i = 0; i < 13; i++) {
                System.out.println((char)(97 + i));
            }
        } else if(zeroCnt == 1) {
            System.out.println(onlyOne);
        } else {
            System.out.println("Impossible");
        }
    }
}
0