結果
問題 | No.548 国士無双 |
ユーザー |
![]() |
提出日時 | 2020-11-04 11:46:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 133 ms / 2,000 ms |
コード長 | 737 bytes |
コンパイル時間 | 2,305 ms |
コンパイル使用メモリ | 83,948 KB |
実行使用メモリ | 41,516 KB |
最終ジャッジ日時 | 2024-07-22 09:55:00 |
合計ジャッジ時間 | 6,867 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
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); } } }