結果

問題 No.305 鍵(2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-11-27 23:51:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,193 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 24,448 KB
平均クエリ数 48.00
最終ジャッジ日時 2023-09-23 06:50:10
合計ジャッジ時間 2,048 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 42 ms
23,904 KB
testcase_02 AC 41 ms
23,992 KB
testcase_03 AC 42 ms
23,932 KB
testcase_04 AC 46 ms
24,392 KB
testcase_05 AC 47 ms
23,820 KB
testcase_06 AC 39 ms
24,420 KB
testcase_07 WA -
testcase_08 AC 43 ms
24,448 KB
testcase_09 AC 43 ms
23,864 KB
testcase_10 AC 43 ms
23,956 KB
testcase_11 AC 43 ms
24,360 KB
testcase_12 AC 44 ms
24,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import sys

DIGITS = 10


class Key(object):

    def __init__(self):
        self.guess = [0] * DIGITS
        self.status = -1
        self.query = 0

    @property
    def guess_int(self):
        return sum(x * y for (x, y) in zip(self.guess,
                                           [10 ** e for e in range(DIGITS - 1, -1, -1)]))

    def get_status(self):
        self.query += 1
        print("{guess:0=10d}".format(guess=self.guess_int))
        [n, _] = input().split()
        self.status = int(n)
        if self.status == DIGITS:
            sys.exit(0)

    def communicate(self):
        for d in range(DIGITS):
            for x in range(10):
                self.guess[d] = x
                s = int(self.status)
                self.get_status()
                if s == -1:
                    continue
                elif s == self.status:
                    continue
                elif s < self.status:
                    break
                elif s > self.status:
                    self.guess[d] -= 1
                    break


def main():
    k = Key()
    k.communicate()


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