結果

問題 No.2879 Range Flip Queries
ユーザー 学ぶマン
提出日時 2025-02-06 21:55:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 940 ms / 2,000 ms
コード長 1,255 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 237,628 KB
最終ジャッジ日時 2025-02-06 21:56:06
合計ジャッジ時間 30,560 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math; sys.setrecursionlimit(10**8); sys.set_int_max_str_digits(0)
inf = 1<<60; MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
def I():   return sys.stdin.readline().rstrip()
def II():  return int(sys.stdin.readline().rstrip())
def IS():  return sys.stdin.readline().rstrip().split()
def MII(): return map(int, sys.stdin.readline().rstrip().split())
def LI():  return list(sys.stdin.readline().rstrip())
def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split()))
def LII(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LSI(): return list(map(str, sys.stdin.readline().rstrip().split()))
def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
def kiriage(a, b): return (a+b-1)//b

N, Q = MII()
A = LII()
LR = [TII() for _ in range(Q)]

memo = [0] * (N + 1)
for l, r in LR:
    l -= 1
    r -= 1
    # [l] に+1
    # [r+1] に-1
    memo[l] += 1
    memo[r + 1] -= 1
memo = list(accumulate(memo))

ans = []
for i in range(N):
    tmp = (A[i] + memo[i])%2
    ans.append(tmp)
print(*ans)
0