結果

問題 No.1149 色塗りゲーム
ユーザー hedwig100
提出日時 2020-08-07 22:22:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 1,198 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 28,160 KB
平均クエリ数 2.32
最終ジャッジ日時 2024-07-17 04:50:03
合計ジャッジ時間 7,107 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 47 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    if N == 1:
        print(1,1,flush = True)
        t = int(input())
        return

    now = [0] * N
    if N%2 == 0:
        print(1,2,flush = True)
        now[1] = 1
    else:
        print(2,2,flush = True)
        now[1] = 1
        now[2] = 1

    while True:
        t = int(input())
        if t == 0:
            return
        elif t == 1:
            return
        elif t >= 2:
            k,x = map(int,input().split())
        if k == 1:
            now[x - 1] = 1
        else:
            now[x - 1] = 1
            now[x] = 1
        
        state = []
        cnt = 0
        st = 0
        for i in range(N):
            if now[i] == 1:
                if cnt > 0:
                    state.append((st,cnt))
                    cnt = 0
                    st = i + 1
            else:
                cnt += 1
        if all(k[1]%2 == 0 for k in state):
            print(1,state[0][0] + 1,flush = True)
        else:
            for s,c in state:
                if c%2 == 1:
                    print(2,s + 1,flush = True)

if __name__ == '__main__':
    main()
0