結果

問題 No.1149 色塗りゲーム
ユーザー もりを
提出日時 2020-08-07 21:38:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 90,860 KB
平均クエリ数 5.30
最終ジャッジ日時 2024-07-17 04:21:06
合計ジャッジ時間 8,221 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby as gb

n = int(input())

a = [False for _ in range(n)]

def check(l):
    xr = 0
    for i in l:
        xr ^= i
    return xr == 0

def nim():
    l = []
    idx = 0
    for k, v in gb(a):
        sz = len(list(v))
        if k == False:
            l.append(sz)
        idx += sz
    return l

while True:
    nxt = [-1, -1]
    # 1個ぬり
    for i in range(n):
        if nxt[0] != -1:
            break
        if a[i] == False:
            a[i] = True
            if check(nim()):
                nxt = [1, i]
                break
            a[i] = False
    # 2個ぬり
    for i in range(n - 1):
        if nxt[0] != -1:
            break
        if a[i] == False and a[i + 1] == False:
            a[i], a[i + 1] = True, True
            if check(nim()):
                nxt = [2, i]
                break
            a[i], a[i + 1] = False, False
    print(nxt[0], nxt[1] + 1)
    t = int(input())
    if t in (0, 1):
        exit(0)
    k, x = map(int,input().split())
    if t == 2:
        exit(0)
    if k == 1:
        a[x - 1] = True
    else:
        a[x - 1], a[x] = True, True
0