結果

問題 No.355 数当てゲーム(2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-04-01 23:07:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,257 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 25,032 KB
平均クエリ数 18.50
最終ジャッジ日時 2023-09-23 09:25:13
合計ジャッジ時間 7,255 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
24,680 KB
testcase_01 WA -
testcase_02 AC 44 ms
24,376 KB
testcase_03 AC 43 ms
24,484 KB
testcase_04 WA -
testcase_05 AC 43 ms
24,612 KB
testcase_06 WA -
testcase_07 AC 44 ms
24,140 KB
testcase_08 AC 45 ms
24,396 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 43 ms
24,284 KB
testcase_12 AC 44 ms
24,132 KB
testcase_13 WA -
testcase_14 AC 44 ms
24,444 KB
testcase_15 AC 44 ms
24,460 KB
testcase_16 AC 44 ms
24,436 KB
testcase_17 AC 45 ms
24,360 KB
testcase_18 AC 44 ms
24,824 KB
testcase_19 WA -
testcase_20 AC 43 ms
24,168 KB
testcase_21 AC 44 ms
24,776 KB
testcase_22 AC 44 ms
24,408 KB
testcase_23 AC 43 ms
24,204 KB
testcase_24 AC 43 ms
24,592 KB
testcase_25 AC 43 ms
24,316 KB
testcase_26 AC 43 ms
24,680 KB
testcase_27 AC 43 ms
24,608 KB
testcase_28 WA -
testcase_29 AC 43 ms
24,396 KB
testcase_30 WA -
testcase_31 AC 44 ms
24,872 KB
testcase_32 AC 43 ms
24,392 KB
testcase_33 AC 44 ms
24,236 KB
testcase_34 WA -
testcase_35 AC 43 ms
24,708 KB
testcase_36 AC 42 ms
24,280 KB
testcase_37 AC 44 ms
24,756 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 43 ms
24,640 KB
testcase_41 WA -
testcase_42 AC 43 ms
24,348 KB
testcase_43 AC 43 ms
24,296 KB
testcase_44 AC 44 ms
24,728 KB
testcase_45 AC 43 ms
24,304 KB
testcase_46 WA -
testcase_47 AC 44 ms
24,400 KB
testcase_48 AC 43 ms
24,800 KB
testcase_49 AC 45 ms
24,748 KB
testcase_50 WA -
testcase_51 AC 45 ms
24,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import collections
import sys


MAX_D = 4
Status = collections.namedtuple("Status", "hit blow")
FINAL = Status(4, 0)


def is_valid_number(seq):
    return len(seq) == len(set(seq))


def submit_guess(guess_seq):
    print(" ".join(map(str, guess_seq)))
    sys.stdout.flush()
    return Status(*map(int, input().split()))


def main():
    guess_seq = array.array("B", [0, 1, 2, 3])
    prev_status= submit_guess(guess_seq)
    status = prev_status
    if status == FINAL:
        return
    for place in range(MAX_D)[::-1]:
        for digit in range(10):
            prev_digit = guess_seq[place]
            guess_seq[place] = digit
            if not is_valid_number(guess_seq):
                guess_seq[place] = prev_digit
                continue
            status = submit_guess(guess_seq)
            if status == FINAL:
                return
            elif prev_status.hit < status.hit:
                prev_status = status
                break
            elif prev_status.hit > status.hit:
                guess_seq[place] = prev_digit
                status = prev_status
                break
            else:
                continue


if __name__ == '__main__':
    main()
0