結果

問題 No.587 七対子
ユーザー Pump0129Pump0129
提出日時 2018-03-26 22:11:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,653 bytes
コンパイル時間 2,416 ms
コンパイル使用メモリ 85,924 KB
実行使用メモリ 57,888 KB
最終ジャッジ日時 2023-09-07 13:19:58
合計ジャッジ時間 8,862 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,120 KB
testcase_01 AC 120 ms
56,056 KB
testcase_02 AC 119 ms
55,752 KB
testcase_03 AC 117 ms
55,656 KB
testcase_04 AC 120 ms
55,680 KB
testcase_05 AC 123 ms
55,664 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 121 ms
56,048 KB
testcase_10 AC 117 ms
55,968 KB
testcase_11 WA -
testcase_12 AC 124 ms
56,148 KB
testcase_13 AC 118 ms
56,028 KB
testcase_14 AC 117 ms
57,888 KB
testcase_15 AC 120 ms
55,644 KB
testcase_16 AC 118 ms
56,036 KB
testcase_17 AC 123 ms
56,036 KB
testcase_18 AC 124 ms
55,484 KB
testcase_19 AC 126 ms
55,492 KB
testcase_20 AC 122 ms
55,852 KB
testcase_21 AC 120 ms
55,364 KB
testcase_22 AC 121 ms
55,764 KB
testcase_23 AC 118 ms
55,852 KB
testcase_24 AC 118 ms
56,260 KB
testcase_25 AC 124 ms
55,928 KB
testcase_26 AC 120 ms
55,836 KB
testcase_27 AC 120 ms
56,112 KB
testcase_28 WA -
testcase_29 AC 120 ms
55,892 KB
testcase_30 AC 121 ms
55,728 KB
testcase_31 AC 123 ms
55,732 KB
testcase_32 AC 126 ms
56,100 KB
testcase_33 AC 122 ms
55,828 KB
testcase_34 AC 119 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no587;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        //文字列ソート処理
        List<String> piece_list = Arrays.asList(scan.nextLine().split(""));
        Collections.sort(piece_list);
        String piece = "";
        for (String tile : piece_list) piece += tile;

        // テキスト終了用 0x03 付与
        piece += String.valueOf((char) 0x03);

        scan.close();

        char missing = 0x00;
        boolean isError = false;

        while (piece.length() != 0 && !isError){
            char c_pair = 0x00;
            for (int i = 0; i < piece.length() ; i++){
                if (i == 0) c_pair = piece.charAt(i);
                else {
                    if (c_pair != piece.charAt(i)) {
                        if (i == 1){
                            if (missing == 0x00) {
                                missing = c_pair;
                            }else {
                                isError = true;
                            }
                        }
                        piece = piece.replaceAll(String.valueOf(c_pair), "");
                        break;
                    }
                }
            }
            //残テキストが0x03のみなら終了
            if (piece.charAt(0) == 0x03) {
                break;
            }
        }

        if (isError || missing == 0x00) {
            System.out.println("Impossible");
        }else {
            System.out.println(missing);
        }
    }
}
0