結果
問題 | No.548 国士無双 |
ユーザー | fkwnw3_1243 |
提出日時 | 2017-09-06 22:52:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,821 bytes |
コンパイル時間 | 10,104 ms |
コンパイル使用メモリ | 77,140 KB |
実行使用メモリ | 53,504 KB |
最終ジャッジ日時 | 2023-10-17 16:20:36 |
合計ジャッジ時間 | 6,074 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
53,500 KB |
testcase_01 | AC | 51 ms
52,404 KB |
testcase_02 | AC | 53 ms
53,500 KB |
testcase_03 | AC | 51 ms
53,496 KB |
testcase_04 | AC | 51 ms
53,496 KB |
testcase_05 | AC | 51 ms
53,500 KB |
testcase_06 | AC | 52 ms
53,496 KB |
testcase_07 | AC | 52 ms
53,496 KB |
testcase_08 | AC | 53 ms
53,500 KB |
testcase_09 | AC | 51 ms
53,496 KB |
testcase_10 | AC | 51 ms
52,432 KB |
testcase_11 | AC | 51 ms
53,504 KB |
testcase_12 | AC | 53 ms
53,492 KB |
testcase_13 | AC | 50 ms
51,464 KB |
testcase_14 | AC | 51 ms
53,496 KB |
testcase_15 | AC | 51 ms
53,500 KB |
testcase_16 | AC | 57 ms
53,504 KB |
testcase_17 | AC | 52 ms
53,500 KB |
testcase_18 | AC | 51 ms
53,500 KB |
testcase_19 | AC | 52 ms
53,500 KB |
testcase_20 | AC | 51 ms
53,496 KB |
testcase_21 | AC | 52 ms
53,500 KB |
testcase_22 | AC | 54 ms
53,496 KB |
testcase_23 | AC | 54 ms
53,440 KB |
ソースコード
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); } }