結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
24,524 KB
testcase_01 WA -
testcase_02 AC 44 ms
24,644 KB
testcase_03 AC 43 ms
24,336 KB
testcase_04 WA -
testcase_05 AC 43 ms
24,928 KB
testcase_06 WA -
testcase_07 AC 44 ms
24,568 KB
testcase_08 AC 44 ms
24,584 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 42 ms
24,172 KB
testcase_12 AC 44 ms
24,360 KB
testcase_13 WA -
testcase_14 AC 44 ms
24,820 KB
testcase_15 AC 45 ms
24,540 KB
testcase_16 AC 44 ms
24,408 KB
testcase_17 AC 44 ms
24,484 KB
testcase_18 AC 43 ms
24,336 KB
testcase_19 WA -
testcase_20 AC 44 ms
24,348 KB
testcase_21 AC 43 ms
24,360 KB
testcase_22 AC 45 ms
24,272 KB
testcase_23 AC 44 ms
24,528 KB
testcase_24 AC 43 ms
24,848 KB
testcase_25 AC 43 ms
24,440 KB
testcase_26 AC 43 ms
24,956 KB
testcase_27 AC 43 ms
24,936 KB
testcase_28 WA -
testcase_29 AC 45 ms
25,024 KB
testcase_30 WA -
testcase_31 AC 44 ms
24,916 KB
testcase_32 AC 43 ms
24,648 KB
testcase_33 AC 44 ms
24,308 KB
testcase_34 WA -
testcase_35 AC 43 ms
24,304 KB
testcase_36 AC 45 ms
24,888 KB
testcase_37 AC 44 ms
24,584 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 43 ms
24,460 KB
testcase_41 WA -
testcase_42 AC 44 ms
24,392 KB
testcase_43 AC 44 ms
24,796 KB
testcase_44 AC 44 ms
24,932 KB
testcase_45 AC 44 ms
24,280 KB
testcase_46 WA -
testcase_47 AC 46 ms
24,836 KB
testcase_48 AC 45 ms
24,228 KB
testcase_49 AC 46 ms
24,368 KB
testcase_50 WA -
testcase_51 AC 43 ms
24,380 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):
            new_seq = guess_seq[:]
            new_seq[place] = digit
            if not is_valid_number(new_seq):
                continue
            status = submit_guess(new_seq)
            if status == FINAL:
                return
            elif prev_status.hit < status.hit:
                guess_seq = new_seq
                prev_status = status
                break
            elif prev_status.hit > status.hit:
                new_seq = guess_seq
                status = prev_status
                break
            else:
                continue


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