結果

問題 No.548 国士無双
ユーザー tentententen
提出日時 2020-11-04 11:46:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 3,865 ms
コンパイル使用メモリ 71,752 KB
実行使用メモリ 55,996 KB
最終ジャッジ日時 2023-09-29 15:45:22
合計ジャッジ時間 5,305 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
53,736 KB
testcase_01 AC 95 ms
55,456 KB
testcase_02 AC 99 ms
55,464 KB
testcase_03 AC 96 ms
55,728 KB
testcase_04 AC 97 ms
55,996 KB
testcase_05 AC 97 ms
55,600 KB
testcase_06 AC 98 ms
55,404 KB
testcase_07 AC 94 ms
55,440 KB
testcase_08 AC 97 ms
55,688 KB
testcase_09 AC 99 ms
55,816 KB
testcase_10 AC 104 ms
55,612 KB
testcase_11 AC 101 ms
55,840 KB
testcase_12 AC 97 ms
55,604 KB
testcase_13 AC 97 ms
55,664 KB
testcase_14 AC 95 ms
55,640 KB
testcase_15 AC 98 ms
55,672 KB
testcase_16 AC 94 ms
55,788 KB
testcase_17 AC 95 ms
55,484 KB
testcase_18 AC 93 ms
55,292 KB
testcase_19 AC 96 ms
55,164 KB
testcase_20 AC 97 ms
55,436 KB
testcase_21 AC 95 ms
55,204 KB
testcase_22 AC 92 ms
55,452 KB
testcase_23 AC 99 ms
55,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int[] counts = new int[13];
		for (char c : arr) {
		    counts[c - 'a']++;
		}
		char x = '0';
		for (int i = 0; i < counts.length; i++) {
		    if (counts[i] == 1 || counts[i] == 2) {
		        continue;
		    } else {
		        if (counts[i] == 0 && x == '0') {
		            x = (char)(i + 'a');
		        } else {
		            System.out.println("Impossible");
		            return;
		        }
		    }
		}
		if (x == '0') {
		    Arrays.sort(arr);
		    for (char c : arr) {
		        System.out.println(c);
		    }
		} else {
		    System.out.println(x);
		}
	}
}
0