結果
問題 | No.355 数当てゲーム(2) |
ユーザー |
![]() |
提出日時 | 2020-02-29 01:50:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,504 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 27,728 KB |
平均クエリ数 | 25.67 |
最終ジャッジ日時 | 2024-07-17 02:34:48 |
合計ジャッジ時間 | 5,709 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#!/usr/bin/env python3# %%import sysreadline = sys.stdin.readlineimport itertools# %%# DEBUG = TrueDEBUG = False# %%class Interactive:def __init__(self):self.ques_cnt = 0self.create_data()def create_data(self):import randomwhile True:N = [random.randint(0, 9) for _ in range(4)]if len(set(N)) < 4:continuebreakself.N = Nprint('created', N)def resp_ques(self, *args):assert len(set(args)) == 4x = 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):passif 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] * 10ask_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] = 1ask_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)