結果
問題 | No.548 国士無双 |
ユーザー |
![]() |
提出日時 | 2017-09-06 22:52:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,821 bytes |
コンパイル時間 | 3,519 ms |
コンパイル使用メモリ | 78,108 KB |
実行使用メモリ | 51,964 KB |
最終ジャッジ日時 | 2024-09-17 13:45:41 |
合計ジャッジ時間 | 5,523 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.Arrays; import static java.lang.System.in; public class No548 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String S = reader.readLine(); int[] table = new int[13]; for (int i = 0; i < 13; i++) { int characterAsInt = S.charAt(i) - 97; if (0 <= characterAsInt && characterAsInt <= 12) { table[characterAsInt] += 1; } } if (allOne(table)) { for (int i = 0; i < 13; i++) { System.out.println((char) (97 + i)); } } else if (one2AndEleven1AndOne0(table)) { for (int i = 0; i < 13; i++) { if(table[i] == 0) { System.out.println((char) (i + 97)); } } } else { System.out.println("Impossible"); } } private static boolean allOne(int[] table) { for (int i = 0; i < 13; i++) { if (table[i] != 1) { return false; } } return true; } private static boolean one2AndEleven1AndOne0(int[] table) { int counterFor2 = 0; int counterFor1 = 0; int counterFor0 = 0; for (int i = 0; i < 13; i++) { if (table[i] == 2) { counterFor2 += 1; } else if (table[i] == 1) { counterFor1 += 1; } else if (table[i] == 0) { counterFor0 += 1; } } return (counterFor2 == 1) && (counterFor1 == 11) && (counterFor0 == 1); } }