結果

問題 No.355 数当てゲーム(2)
ユーザー cielciel
提出日時 2016-04-01 23:25:10
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,540 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 78,156 KB
実行使用メモリ 117,280 KB
平均クエリ数 5.19
最終ジャッジ日時 2023-09-23 23:30:39
合計ジャッジ時間 59,124 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,530 ms
116,792 KB
testcase_01 AC 1,280 ms
116,556 KB
testcase_02 AC 1,428 ms
116,200 KB
testcase_03 AC 442 ms
115,196 KB
testcase_04 AC 564 ms
116,632 KB
testcase_05 AC 424 ms
114,960 KB
testcase_06 AC 1,284 ms
115,568 KB
testcase_07 AC 680 ms
115,736 KB
testcase_08 AC 1,224 ms
117,020 KB
testcase_09 AC 308 ms
115,556 KB
testcase_10 AC 689 ms
116,884 KB
testcase_11 AC 1,540 ms
116,688 KB
testcase_12 AC 375 ms
114,716 KB
testcase_13 AC 390 ms
115,316 KB
testcase_14 AC 263 ms
115,084 KB
testcase_15 AC 1,510 ms
116,936 KB
testcase_16 AC 1,319 ms
116,460 KB
testcase_17 AC 439 ms
114,824 KB
testcase_18 AC 1,270 ms
115,660 KB
testcase_19 AC 1,527 ms
116,652 KB
testcase_20 AC 326 ms
116,364 KB
testcase_21 AC 399 ms
116,028 KB
testcase_22 AC 1,438 ms
116,040 KB
testcase_23 AC 1,244 ms
117,244 KB
testcase_24 AC 1,417 ms
116,776 KB
testcase_25 AC 267 ms
115,168 KB
testcase_26 AC 378 ms
115,440 KB
testcase_27 AC 283 ms
114,588 KB
testcase_28 AC 404 ms
115,588 KB
testcase_29 AC 1,456 ms
116,764 KB
testcase_30 AC 251 ms
114,784 KB
testcase_31 AC 1,427 ms
117,168 KB
testcase_32 AC 431 ms
115,556 KB
testcase_33 AC 1,235 ms
117,132 KB
testcase_34 AC 308 ms
115,940 KB
testcase_35 AC 1,339 ms
115,748 KB
testcase_36 AC 342 ms
115,840 KB
testcase_37 AC 323 ms
115,024 KB
testcase_38 AC 273 ms
114,392 KB
testcase_39 AC 1,467 ms
116,728 KB
testcase_40 AC 525 ms
115,196 KB
testcase_41 AC 1,477 ms
117,124 KB
testcase_42 AC 1,411 ms
116,492 KB
testcase_43 AC 1,212 ms
117,280 KB
testcase_44 AC 1,457 ms
116,260 KB
testcase_45 AC 1,152 ms
116,256 KB
testcase_46 AC 363 ms
115,480 KB
testcase_47 AC 1,096 ms
115,704 KB
testcase_48 AC 298 ms
115,896 KB
testcase_49 AC 546 ms
115,920 KB
testcase_50 AC 387 ms
115,864 KB
testcase_51 AC 1,404 ms
116,212 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 random.choice(lst)
	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