結果

問題 No.355 数当てゲーム(2)
ユーザー maspymaspy
提出日時 2020-02-29 01:50:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,504 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,120 KB
実行使用メモリ 24,696 KB
平均クエリ数 25.67
最終ジャッジ日時 2023-09-24 02:31:25
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
24,296 KB
testcase_01 AC 40 ms
24,512 KB
testcase_02 AC 39 ms
24,088 KB
testcase_03 AC 41 ms
24,488 KB
testcase_04 AC 41 ms
24,008 KB
testcase_05 AC 41 ms
24,112 KB
testcase_06 AC 41 ms
24,208 KB
testcase_07 AC 41 ms
24,164 KB
testcase_08 AC 40 ms
24,352 KB
testcase_09 AC 40 ms
24,540 KB
testcase_10 AC 41 ms
24,696 KB
testcase_11 AC 40 ms
24,396 KB
testcase_12 AC 41 ms
24,536 KB
testcase_13 AC 41 ms
24,188 KB
testcase_14 AC 40 ms
24,380 KB
testcase_15 AC 40 ms
24,480 KB
testcase_16 AC 39 ms
24,052 KB
testcase_17 AC 39 ms
24,304 KB
testcase_18 AC 38 ms
23,908 KB
testcase_19 AC 39 ms
24,560 KB
testcase_20 AC 40 ms
23,920 KB
testcase_21 AC 40 ms
24,312 KB
testcase_22 AC 41 ms
23,924 KB
testcase_23 AC 40 ms
24,068 KB
testcase_24 AC 42 ms
24,316 KB
testcase_25 AC 41 ms
24,516 KB
testcase_26 AC 40 ms
24,608 KB
testcase_27 AC 40 ms
24,368 KB
testcase_28 AC 40 ms
24,196 KB
testcase_29 AC 40 ms
24,468 KB
testcase_30 AC 39 ms
24,180 KB
testcase_31 AC 38 ms
24,636 KB
testcase_32 AC 42 ms
24,088 KB
testcase_33 AC 40 ms
24,096 KB
testcase_34 AC 42 ms
24,256 KB
testcase_35 AC 41 ms
24,300 KB
testcase_36 AC 40 ms
24,076 KB
testcase_37 AC 41 ms
24,588 KB
testcase_38 AC 40 ms
24,364 KB
testcase_39 AC 41 ms
24,500 KB
testcase_40 AC 40 ms
23,824 KB
testcase_41 AC 40 ms
24,256 KB
testcase_42 AC 39 ms
24,428 KB
testcase_43 AC 39 ms
24,092 KB
testcase_44 AC 40 ms
24,236 KB
testcase_45 AC 41 ms
24,604 KB
testcase_46 AC 40 ms
24,072 KB
testcase_47 AC 41 ms
24,000 KB
testcase_48 AC 41 ms
24,068 KB
testcase_49 AC 40 ms
24,568 KB
testcase_50 AC 41 ms
23,896 KB
testcase_51 AC 41 ms
24,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
readline = sys.stdin.readline
import itertools
# %%
# DEBUG = True
DEBUG = False


# %%
class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()

    def create_data(self):
        import random
        while True:
            N = [random.randint(0, 9) for _ in range(4)]
            if len(set(N)) < 4:
                continue
            break
        self.N = N
        print('created', N)

    def resp_ques(self, *args):
        assert len(set(args)) == 4
        x = sum(a == b for a, b in zip(self.N, args))
        xy = len(set(self.N) & set(args))
        return f'{x} {xy-x}\n'

    def resp_ans(self, *args):
        pass


if DEBUG:
    interactive = Interactive()


def question(*args, offset=None):
    if offset is None:
        print(*args, flush=True)
    else:
        print(offset, *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp, end='')
    else:
        resp = readline()
    x,y = map(int,resp.split())
    if x == 4:
        exit()
    return x,y


# %%
exists = [0] * 10
ask_789 = [sum(question(x,7,8,9)) for x in range(7)]
for i in range(7):
    if ask_789[i] == max(ask_789):
        exists[i] = 1
ask_012 = [sum(question(x+3,0,1,2)) for x in range(7)]
for i in range(7):
    if ask_012[i] == max(ask_012):
        exists[i+3] = 1


# %%
nums = [i for i,x in enumerate(exists) if x]
for a,b,c,d in itertools.permutations(nums):
    question(a,b,c,d)
0