結果
問題 | No.355 数当てゲーム(2) |
ユーザー | ciel |
提出日時 | 2016-04-01 23:21:06 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 1,862 ms / 2,000 ms |
コード長 | 1,368 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 77,544 KB |
実行使用メモリ | 117,684 KB |
平均クエリ数 | 5.38 |
最終ジャッジ日時 | 2023-09-23 09:33:45 |
合計ジャッジ時間 | 65,317 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,727 ms
116,200 KB |
testcase_01 | AC | 379 ms
114,928 KB |
testcase_02 | AC | 1,409 ms
116,512 KB |
testcase_03 | AC | 1,488 ms
116,488 KB |
testcase_04 | AC | 1,449 ms
116,904 KB |
testcase_05 | AC | 1,438 ms
117,368 KB |
testcase_06 | AC | 1,454 ms
117,180 KB |
testcase_07 | AC | 337 ms
115,180 KB |
testcase_08 | AC | 1,419 ms
117,348 KB |
testcase_09 | AC | 380 ms
115,008 KB |
testcase_10 | AC | 304 ms
115,184 KB |
testcase_11 | AC | 1,415 ms
116,564 KB |
testcase_12 | AC | 1,399 ms
116,888 KB |
testcase_13 | AC | 677 ms
116,296 KB |
testcase_14 | AC | 355 ms
114,884 KB |
testcase_15 | AC | 661 ms
116,652 KB |
testcase_16 | AC | 1,468 ms
117,144 KB |
testcase_17 | AC | 1,457 ms
116,736 KB |
testcase_18 | AC | 362 ms
115,064 KB |
testcase_19 | AC | 1,827 ms
116,932 KB |
testcase_20 | AC | 1,862 ms
116,684 KB |
testcase_21 | AC | 300 ms
115,240 KB |
testcase_22 | AC | 1,438 ms
116,952 KB |
testcase_23 | AC | 430 ms
114,596 KB |
testcase_24 | AC | 228 ms
114,432 KB |
testcase_25 | AC | 650 ms
116,092 KB |
testcase_26 | AC | 1,824 ms
116,932 KB |
testcase_27 | AC | 681 ms
116,276 KB |
testcase_28 | AC | 462 ms
115,136 KB |
testcase_29 | AC | 1,431 ms
117,056 KB |
testcase_30 | AC | 1,492 ms
116,952 KB |
testcase_31 | AC | 1,436 ms
116,672 KB |
testcase_32 | AC | 334 ms
115,232 KB |
testcase_33 | AC | 1,503 ms
117,684 KB |
testcase_34 | AC | 1,757 ms
117,388 KB |
testcase_35 | AC | 346 ms
115,012 KB |
testcase_36 | AC | 380 ms
115,292 KB |
testcase_37 | AC | 1,708 ms
116,408 KB |
testcase_38 | AC | 1,826 ms
116,900 KB |
testcase_39 | AC | 1,823 ms
116,888 KB |
testcase_40 | AC | 419 ms
114,416 KB |
testcase_41 | AC | 1,340 ms
116,776 KB |
testcase_42 | AC | 1,405 ms
116,668 KB |
testcase_43 | AC | 632 ms
116,060 KB |
testcase_44 | AC | 1,426 ms
117,340 KB |
testcase_45 | AC | 1,735 ms
116,276 KB |
testcase_46 | AC | 1,804 ms
117,080 KB |
testcase_47 | AC | 1,434 ms
116,920 KB |
testcase_48 | AC | 362 ms
115,132 KB |
testcase_49 | AC | 1,420 ms
117,624 KB |
testcase_50 | AC | 1,412 ms
117,080 KB |
testcase_51 | AC | 1,673 ms
116,340 KB |
ソースコード
#!/usr/bin/python from collections import Counter import itertools,random digits=4 #mode='mastermind' mode='hitandblow' def hit_and_blow(a,b): hit=sum(a[i]==b[i] for i in range(digits)) if mode=='mastermind': #mastermind allows duplication (slow) ca=Counter(a) cb=Counter(b) blow=sum(min(0 if k not in cb else cb[k],v) for k,v in ca.items()) else: 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(): if mode=='mastermind': return list(''.join(e) for e in itertools.product(iter('123456'),repeat=digits)) else: return list(''.join(e) for e in itertools.permutations(iter('0123456789'),digits)) def checkio(data): global lst if len(data)==0: lst=genlist() if mode=='mastermind': return '1122' else: return '4567' 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 if sys.version_info[0]>=3: raw_input=input 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()))