結果
問題 | No.355 数当てゲーム(2) |
ユーザー | はむ吉🐹 |
提出日時 | 2016-04-04 18:18:07 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 28,888 KB |
平均クエリ数 | 5.42 |
最終ジャッジ日時 | 2024-07-16 23:32:06 |
合計ジャッジ時間 | 6,412 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
28,376 KB |
testcase_01 | AC | 68 ms
28,632 KB |
testcase_02 | AC | 68 ms
28,376 KB |
testcase_03 | AC | 70 ms
28,376 KB |
testcase_04 | AC | 70 ms
28,760 KB |
testcase_05 | AC | 67 ms
28,888 KB |
testcase_06 | AC | 65 ms
28,376 KB |
testcase_07 | AC | 66 ms
28,376 KB |
testcase_08 | AC | 63 ms
28,112 KB |
testcase_09 | AC | 67 ms
28,376 KB |
testcase_10 | AC | 68 ms
28,376 KB |
testcase_11 | AC | 67 ms
28,120 KB |
testcase_12 | AC | 71 ms
28,376 KB |
testcase_13 | AC | 71 ms
28,632 KB |
testcase_14 | AC | 73 ms
28,760 KB |
testcase_15 | AC | 65 ms
28,760 KB |
testcase_16 | AC | 71 ms
28,376 KB |
testcase_17 | AC | 66 ms
28,632 KB |
testcase_18 | AC | 65 ms
28,376 KB |
testcase_19 | AC | 70 ms
28,632 KB |
testcase_20 | AC | 63 ms
28,240 KB |
testcase_21 | AC | 68 ms
28,112 KB |
testcase_22 | AC | 66 ms
28,880 KB |
testcase_23 | AC | 69 ms
28,624 KB |
testcase_24 | AC | 69 ms
28,752 KB |
testcase_25 | AC | 69 ms
28,528 KB |
testcase_26 | AC | 69 ms
28,496 KB |
testcase_27 | AC | 65 ms
28,496 KB |
testcase_28 | AC | 66 ms
28,368 KB |
testcase_29 | AC | 66 ms
28,240 KB |
testcase_30 | AC | 69 ms
28,112 KB |
testcase_31 | AC | 70 ms
28,488 KB |
testcase_32 | AC | 69 ms
28,648 KB |
testcase_33 | AC | 67 ms
28,496 KB |
testcase_34 | AC | 63 ms
28,368 KB |
testcase_35 | AC | 66 ms
28,616 KB |
testcase_36 | AC | 69 ms
28,264 KB |
testcase_37 | AC | 68 ms
28,488 KB |
testcase_38 | AC | 71 ms
28,360 KB |
testcase_39 | AC | 69 ms
28,360 KB |
testcase_40 | AC | 65 ms
28,392 KB |
testcase_41 | AC | 70 ms
28,488 KB |
testcase_42 | AC | 68 ms
28,616 KB |
testcase_43 | AC | 67 ms
28,104 KB |
testcase_44 | AC | 71 ms
28,488 KB |
testcase_45 | AC | 65 ms
28,368 KB |
testcase_46 | AC | 71 ms
28,368 KB |
testcase_47 | AC | 64 ms
28,112 KB |
testcase_48 | AC | 68 ms
28,112 KB |
testcase_49 | AC | 71 ms
28,240 KB |
testcase_50 | AC | 65 ms
28,752 KB |
testcase_51 | AC | 70 ms
28,496 KB |
ソースコード
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections import itertools import sys MAX_D = 4 Status = collections.namedtuple("Status", "hit blow") FINAL = Status(4, 0) def compute_status(assumptive_answer, guess): hit = sum(int(a == c) for a, c in zip(assumptive_answer, guess)) hit_and_blow = len(set(assumptive_answer) & set(guess)) blow = hit_and_blow - hit return Status(hit, blow) def is_possible_candidate(candidate, prev_guess, prev_status): return compute_status(candidate, prev_guess) == prev_status def generate_all_candidates(d=MAX_D): return set(itertools.permutations(range(10), d)) def submit_guess(guess): print(" ".join(map(str, guess))) sys.stdout.flush() return Status(*map(int, input().split())) def main(): candidates = generate_all_candidates() while candidates: guess = candidates.pop() status = submit_guess(guess) if status == FINAL: return f = lambda c: is_possible_candidate(c, guess, status) candidates = set(filter(f, candidates)) if __name__ == '__main__': main()