結果
問題 |
No.548 国士無双
|
ユーザー |
![]() |
提出日時 | 2017-09-06 22:50:33 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,788 bytes |
コンパイル時間 | 3,160 ms |
コンパイル使用メモリ | 77,616 KB |
実行使用メモリ | 37,048 KB |
最終ジャッジ日時 | 2024-07-05 20:30:49 |
合計ジャッジ時間 | 5,155 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 20 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; 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) (table[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); } }