結果
問題 | No.548 国士無双 |
ユーザー |
![]() |
提出日時 | 2017-07-28 22:33:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 1,275 bytes |
コンパイル時間 | 2,133 ms |
コンパイル使用メモリ | 78,320 KB |
実行使用メモリ | 41,372 KB |
最終ジャッジ日時 | 2024-09-17 13:00:17 |
合計ジャッジ時間 | 5,412 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final char[] ops = "abcdefghijklm".toCharArray(); final char[] chs = sc.next().toCharArray(); int[] count = new int[26]; for(final char ch : chs){ count[ch - 'a']++; } int one_count = 0, two_count = 0; for(final char op : ops){ final int index = op - 'a'; if(count[index] == 1){ one_count++; }else if(count[index] == 2){ two_count++; } } //System.out.println(Arrays.toString(count) + " " + one_count + " " + chs.length); if(two_count >= 2){ System.out.println("Impossible"); }else if(two_count == 1 && one_count == ops.length - 2){ for(final char op : ops){ final int index = op - 'a'; if(count[index] == 0){ System.out.println(op); break; } } }else if(two_count == 0 && one_count == ops.length){ for(final char op : ops){ System.out.println(op); } }else{ System.out.println("Impossible"); } } }