結果

問題 No.1149 色塗りゲーム
コンテスト
ユーザー toyuzuko
提出日時 2020-08-10 21:00:45
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 1,349 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 506 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 34,316 KB
平均クエリ数 0.08
最終ジャッジ日時 2026-03-31 21:05:48
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())

used = [0 for _ in range(N + 2)]
used[0] = 1
used[N + 1] = 1

while True:
    cnt = 0
    for i in range(0, N + 1):
        if used[i] and not used[i + 1]:
            cnt += 1
    if cnt % 2 == 1:
        for i in range(0, N):
            if used[i] and not used[i + 1] and used[i + 2]:
                used[i + 1] = 1
                print(1, i + 1)
                break
        else:
            for i in range(0, N - 1):
                if used[i] and not used[i + 1] and not used[i + 2] and used[i + 3]:
                    used[i + 1] = 1
                    used[i + 2] = 1
                    print(2, i + 1)
                    break
            else:
                for i in range(0, N):
                    if not used[i + 1]:
                        used[i + 2] = 1
                        print(1, i + 2)
                        break
    else:
        for i in range(0, N):
            if used[i] and not used[i + 1] and not used[i + 2]:
                used[i + 1] = 1
                print(1, i + 1)
                break
    t = int(input())
    if t == 0:
        break
    elif t == 1:
        raise Exception
    elif t == 2:
        raise Exception
    else:
        k, x = map(int, input().split())
        if k == 1:
            used[x] = 1
        else:
            used[x] = 1
            used[x + 1] = 1
0