結果

問題 No.355 数当てゲーム(2)
ユーザー cielciel
提出日時 2016-04-01 23:23:52
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,865 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 77,648 KB
実行使用メモリ 118,064 KB
平均クエリ数 5.33
最終ジャッジ日時 2023-09-23 23:28:12
合計ジャッジ時間 57,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 327 ms
115,924 KB
testcase_01 AC 314 ms
115,636 KB
testcase_02 AC 1,457 ms
118,064 KB
testcase_03 AC 653 ms
116,116 KB
testcase_04 AC 688 ms
117,160 KB
testcase_05 AC 351 ms
115,368 KB
testcase_06 AC 683 ms
116,904 KB
testcase_07 AC 1,408 ms
116,324 KB
testcase_08 AC 670 ms
116,780 KB
testcase_09 AC 264 ms
115,176 KB
testcase_10 AC 685 ms
116,724 KB
testcase_11 AC 463 ms
116,292 KB
testcase_12 AC 1,410 ms
117,068 KB
testcase_13 AC 257 ms
114,316 KB
testcase_14 AC 432 ms
115,688 KB
testcase_15 AC 473 ms
116,324 KB
testcase_16 AC 1,417 ms
116,592 KB
testcase_17 AC 642 ms
116,040 KB
testcase_18 AC 683 ms
116,312 KB
testcase_19 AC 307 ms
114,484 KB
testcase_20 AC 393 ms
115,524 KB
testcase_21 AC 1,732 ms
115,924 KB
testcase_22 AC 1,742 ms
116,080 KB
testcase_23 AC 471 ms
115,896 KB
testcase_24 AC 437 ms
114,528 KB
testcase_25 AC 379 ms
114,828 KB
testcase_26 AC 1,865 ms
116,792 KB
testcase_27 AC 308 ms
114,956 KB
testcase_28 AC 295 ms
115,476 KB
testcase_29 AC 1,453 ms
116,356 KB
testcase_30 AC 353 ms
114,388 KB
testcase_31 AC 376 ms
115,324 KB
testcase_32 AC 378 ms
115,892 KB
testcase_33 AC 678 ms
115,216 KB
testcase_34 AC 1,400 ms
116,932 KB
testcase_35 AC 624 ms
115,892 KB
testcase_36 AC 470 ms
115,164 KB
testcase_37 AC 447 ms
115,864 KB
testcase_38 AC 685 ms
115,244 KB
testcase_39 AC 1,429 ms
117,172 KB
testcase_40 AC 445 ms
114,952 KB
testcase_41 AC 428 ms
114,508 KB
testcase_42 AC 263 ms
115,196 KB
testcase_43 AC 682 ms
115,528 KB
testcase_44 AC 457 ms
115,428 KB
testcase_45 AC 279 ms
115,416 KB
testcase_46 AC 310 ms
115,024 KB
testcase_47 AC 381 ms
115,356 KB
testcase_48 AC 1,759 ms
117,684 KB
testcase_49 AC 655 ms
115,564 KB
testcase_50 AC 385 ms
115,256 KB
testcase_51 AC 258 ms
114,652 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