結果

問題 No.587 七対子
ユーザー Pump0129Pump0129
提出日時 2018-03-26 22:14:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,742 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 76,820 KB
実行使用メモリ 56,016 KB
最終ジャッジ日時 2023-09-27 02:22:09
合計ジャッジ時間 8,920 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,824 KB
testcase_01 AC 126 ms
55,484 KB
testcase_02 AC 127 ms
55,564 KB
testcase_03 AC 128 ms
55,400 KB
testcase_04 AC 127 ms
55,728 KB
testcase_05 AC 125 ms
55,340 KB
testcase_06 AC 126 ms
55,476 KB
testcase_07 AC 130 ms
55,720 KB
testcase_08 AC 125 ms
55,664 KB
testcase_09 AC 127 ms
55,636 KB
testcase_10 AC 125 ms
55,632 KB
testcase_11 AC 125 ms
55,984 KB
testcase_12 AC 125 ms
55,564 KB
testcase_13 AC 126 ms
55,592 KB
testcase_14 AC 130 ms
55,732 KB
testcase_15 AC 123 ms
55,632 KB
testcase_16 AC 124 ms
55,720 KB
testcase_17 AC 124 ms
55,676 KB
testcase_18 AC 126 ms
55,856 KB
testcase_19 AC 123 ms
55,724 KB
testcase_20 AC 124 ms
55,368 KB
testcase_21 AC 125 ms
56,016 KB
testcase_22 AC 126 ms
55,504 KB
testcase_23 AC 124 ms
55,996 KB
testcase_24 AC 126 ms
55,880 KB
testcase_25 AC 125 ms
55,332 KB
testcase_26 AC 127 ms
55,816 KB
testcase_27 AC 126 ms
55,528 KB
testcase_28 AC 125 ms
55,852 KB
testcase_29 AC 126 ms
55,676 KB
testcase_30 AC 125 ms
55,268 KB
testcase_31 AC 126 ms
55,736 KB
testcase_32 AC 126 ms
55,700 KB
testcase_33 AC 127 ms
55,596 KB
testcase_34 AC 125 ms
55,688 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;
                            }
                        } else if(3 <= i){
                            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