結果

問題 No.355 数当てゲーム(2)
ユーザー cielciel
提出日時 2016-04-01 23:22:56
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,853 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 77,924 KB
実行使用メモリ 117,952 KB
平均クエリ数 5.12
最終ジャッジ日時 2023-09-23 09:35:27
合計ジャッジ時間 63,619 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 360 ms
115,820 KB
testcase_01 AC 1,808 ms
116,976 KB
testcase_02 AC 1,703 ms
116,532 KB
testcase_03 AC 224 ms
114,444 KB
testcase_04 AC 299 ms
115,452 KB
testcase_05 AC 1,428 ms
116,936 KB
testcase_06 AC 1,814 ms
116,900 KB
testcase_07 AC 1,379 ms
117,540 KB
testcase_08 AC 463 ms
115,580 KB
testcase_09 AC 1,795 ms
117,048 KB
testcase_10 AC 1,769 ms
117,128 KB
testcase_11 AC 254 ms
114,396 KB
testcase_12 AC 1,433 ms
117,464 KB
testcase_13 AC 1,404 ms
116,896 KB
testcase_14 AC 1,694 ms
116,428 KB
testcase_15 AC 1,705 ms
116,468 KB
testcase_16 AC 673 ms
116,304 KB
testcase_17 AC 1,739 ms
116,360 KB
testcase_18 AC 1,359 ms
116,652 KB
testcase_19 AC 1,442 ms
117,112 KB
testcase_20 AC 643 ms
115,888 KB
testcase_21 AC 1,402 ms
117,640 KB
testcase_22 AC 1,705 ms
116,968 KB
testcase_23 AC 1,465 ms
117,412 KB
testcase_24 AC 672 ms
115,828 KB
testcase_25 AC 279 ms
114,988 KB
testcase_26 AC 381 ms
115,360 KB
testcase_27 AC 1,462 ms
117,640 KB
testcase_28 AC 1,472 ms
117,320 KB
testcase_29 AC 673 ms
116,156 KB
testcase_30 AC 1,439 ms
116,728 KB
testcase_31 AC 225 ms
113,868 KB
testcase_32 AC 277 ms
115,728 KB
testcase_33 AC 1,457 ms
117,244 KB
testcase_34 AC 1,694 ms
116,524 KB
testcase_35 AC 1,370 ms
116,332 KB
testcase_36 AC 1,828 ms
116,776 KB
testcase_37 AC 1,438 ms
116,716 KB
testcase_38 AC 1,806 ms
116,760 KB
testcase_39 AC 382 ms
115,560 KB
testcase_40 AC 1,845 ms
117,172 KB
testcase_41 AC 1,827 ms
117,084 KB
testcase_42 AC 311 ms
114,860 KB
testcase_43 AC 461 ms
115,400 KB
testcase_44 AC 225 ms
113,740 KB
testcase_45 AC 1,399 ms
117,048 KB
testcase_46 AC 674 ms
116,632 KB
testcase_47 AC 1,853 ms
117,000 KB
testcase_48 AC 643 ms
116,032 KB
testcase_49 AC 1,468 ms
117,952 KB
testcase_50 AC 1,707 ms
116,660 KB
testcase_51 AC 330 ms
115,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
from collections import Counter
import itertools,random

digits=4

def hit_and_blow(a,b):
	hit=sum(a[i]==b[i] for i in range(digits))
	blow=len(a)+len(b)-len(set(iter(a+b)))
	return (hit,blow-hit)

def minimax(e):
	h={}
	for f in lst:
		x=hit_and_blow(e,f)
		if x not in h: h[x]=0
		h[x]+=1
	return (max(h.values()),e)

def genlist():
	return list(''.join(e) for e in itertools.permutations(iter('0123456789'),digits))

def checkio(data):
	global lst
	if len(data)==0:
		lst=genlist()
		return '2345'
	last=data[-1].split()
	hit=int(last[1][0])
	blow=int(last[1][2])
	last=last[0]
	for i in range(len(lst)-1,-1,-1):
		if hit_and_blow(lst[i],last)!=(hit,blow): lst.pop(i)
	return min(minimax(e) for e in lst)[1]
	#return random.choice(lst)

if __name__ == '__main__':
	import sys
	q=[]
	while True:
		s=checkio(q)
		print(' '.join(s))
		sys.stdout.flush()
		t=raw_input().strip()
		if t=='4 0':break
		q.append(s+' '+'H'.join(t.split()))
0