結果
| 問題 |
No.2848 Birthday Hit and Blow
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 23:42:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 516 ms / 2,000 ms |
| コード長 | 2,397 bytes |
| コンパイル時間 | 267 ms |
| コンパイル使用メモリ | 82,452 KB |
| 実行使用メモリ | 95,644 KB |
| 平均クエリ数 | 573.50 |
| 最終ジャッジ日時 | 2024-08-23 23:42:21 |
| 合計ジャッジ時間 | 1,716 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 |
ソースコード
from math import gcd
import sys, time, random
from collections import deque, Counter, defaultdict
def debug(*x):print('debug:',*x, file=sys.stderr)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
S = set()
for month in range(1, 13):
for day in range(1, 32):
if month in [4, 6, 9, 11] and day == 31:
continue
if month == 2 and day > 29:
continue
st = str(month).zfill(2) + str(day).zfill(2)
if len(set(st)) == 4:
S.add(st)
ST = []
for i1 in range(3):
for i2 in range(3):
for i3 in range(3):
for i4 in range(10):
if i1 == i2 or i1 == i3 or i1 == i4 or i2 == i3 or i2 == i4 or i3 == i4:
continue
st = str(i1) + str(i2) + str(i3) + str(i4)
ST.append(st)
def solve():
nowS = set(S)
deb = False
if deb:
ANS = random.choice(list(nowS))
debug(ANS)
for q in range(6):
bestq = None
bestmax = inf
bestans = None
for st in ST:
ans = defaultdict(list)
for v in nowS:
h = 0
b = 0
for i in range(4):
if st[i] == v[i]:
h += 1
elif st[i] in v:
b += 1
ans[(h, b)].append(v)
V = [len(v) for v in ans.values()]
if max(V) < bestmax:
bestmax = max(V)
bestq = st
bestans = ans
print('?', bestq, flush=True)
if deb:
h = 0
b = 0
for i in range(4):
if bestq[i] == ANS[i]:
h += 1
elif bestq[i] in ANS:
b += 1
else:
h, b = mi()
nowS = bestans[(h, b)]
if len(nowS) == 1:
A = nowS.pop()
print('!', A, flush=True)
if deb:
if A == ANS:
a = 0
else:
a = -1
else:
a = ii()
if a == 0:
pass
else:
raise ValueError
return
for _ in range(ii()):
solve()