結果
| 問題 | No.355 数当てゲーム(2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-10-29 12:40:01 | 
| 言語 | Python2 (2.7.18) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 33 ms / 2,000 ms | 
| コード長 | 948 bytes | 
| コンパイル時間 | 196 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 25,604 KB | 
| 平均クエリ数 | 32.69 | 
| 最終ジャッジ日時 | 2024-07-17 00:35:02 | 
| 合計ジャッジ時間 | 4,605 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 52 | 
ソースコード
import sys
def communicate(S):
    print S
    sys.stdout.flush()
    ans = map(int, raw_input().split())
    if ans == [4, 0]:
        exit()
    return ans
ans = [-1, -1, -1, -1]
for keta in xrange(4):
    others = ['7','8','9']
    hits = []
    for i in xrange(7):
        hit, blow = communicate(' '.join(others[:keta]+[str(i)]+others[keta:]))
        hits.append(hit)
    for i in xrange(7):
        if hits[0] > hits[i]:
            ans[keta] = 0
            break
        elif hits[0] < hits[i]:
            ans[keta] = i
    if ans[keta] != -1:
        continue
    
    others = ['0','1','2']
    hits = []
    for i in xrange(7, 10):
        hit, blow = communicate(' '.join(others[:keta]+[str(i)]+others[keta:]))
        hits.append(hit)
    for i in xrange(3):
        if hits[0] > hits[i]:
            ans[keta] = 7
            break
        elif hits[0] < hits[i]:
            ans[keta] = 7+i
communicate(' '.join(map(str, ans)))
            
            
            
        