結果
問題 | No.587 七対子 |
ユーザー | kohaku_kohaku |
提出日時 | 2019-02-21 23:16:24 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 74,584 KB |
実行使用メモリ | 54,432 KB |
最終ジャッジ日時 | 2024-05-01 08:57:17 |
合計ジャッジ時間 | 7,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
54,192 KB |
testcase_01 | AC | 121 ms
53,848 KB |
testcase_02 | AC | 125 ms
54,064 KB |
testcase_03 | AC | 121 ms
54,104 KB |
testcase_04 | AC | 125 ms
54,024 KB |
testcase_05 | AC | 123 ms
54,028 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 118 ms
53,832 KB |
testcase_10 | AC | 118 ms
54,104 KB |
testcase_11 | WA | - |
testcase_12 | AC | 116 ms
54,080 KB |
testcase_13 | AC | 120 ms
54,216 KB |
testcase_14 | AC | 118 ms
53,712 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 116 ms
53,836 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 123 ms
53,848 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 121 ms
53,896 KB |
testcase_31 | WA | - |
testcase_32 | AC | 119 ms
53,804 KB |
testcase_33 | AC | 122 ms
54,064 KB |
testcase_34 | AC | 120 ms
54,328 KB |
ソースコード
import java.util.Scanner; public class Main { static public void main(String[]args) throws Exception { Scanner sc = new Scanner(System.in); String s = sc.next(); solve(s); } static void solve(String s) throws Exception { int [] alphabet = new int[26]; for(int i=0; i<s.length(); i++) { int tmp = s.charAt(i) - 'a'; alphabet[tmp]++; } int ans = searchAns(alphabet); if(ans == -1) { System.out.println("Impossible"); } else { System.out.println( (char)('a' + ans) ); } } static int searchAns(int [] alphabet) throws Exception { final int NUM_ALPHABET = 26; int count = -1; for(int i=0; i < NUM_ALPHABET; i++) { if(alphabet[i] == 0 || alphabet[i] == 2) { //nothing } else if(alphabet[i] == 1) { if(count == -1) { count = i; } else { break; } } else { break; } } return count; } }