結果
問題 | No.355 数当てゲーム(2) |
ユーザー |
![]() |
提出日時 | 2021-03-31 04:49:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 81,224 KB |
実行使用メモリ | 93,508 KB |
平均クエリ数 | 5.12 |
最終ジャッジ日時 | 2024-07-17 03:01:00 |
合計ジャッジ時間 | 8,174 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
def g(x,v): aa = bb = 0 for i in range(4): if v[i] == x[i]: aa += 1 elif v[i] in x: bb += 1 return aa,bb def check(x,v,a,b): aa,bb = g(x,v) return aa==a and bb==b def query(v): print(*v) if DEBUG: a,b = g(v,ans) else: a,b = map(int,input().split()) return a,b DEBUG = 0 ans = "1864" from itertools import permutations s = {"".join(map(str,i)) for i in permutations(range(10),4)} c = 0 while True: v = s.pop() a,b = query(v) if a==4: exit() ns = set() for i in s: if check(i,v,a,b): ns.add(i) s = ns