結果

問題 No.1673 Lamps on a line
ユーザー moharan627moharan627
提出日時 2021-09-10 21:25:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 12,760 KB
最終ジャッジ日時 2023-09-02 15:50:04
合計ジャッジ時間 2,641 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,588 KB
testcase_01 AC 18 ms
8,408 KB
testcase_02 AC 99 ms
9,016 KB
testcase_03 AC 98 ms
8,820 KB
testcase_04 AC 163 ms
8,960 KB
testcase_05 AC 27 ms
8,940 KB
testcase_06 AC 148 ms
8,852 KB
testcase_07 AC 164 ms
11,704 KB
testcase_08 AC 22 ms
10,484 KB
testcase_09 AC 233 ms
9,300 KB
testcase_10 AC 243 ms
10,664 KB
testcase_11 AC 39 ms
10,384 KB
testcase_12 AC 294 ms
12,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20,2**63に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N,Q = MI()
    Lump = [0]*(N+1)
    Ans = 0
    for q in range(Q):
        L,R = MI()
        for i in range(L,R+1):
            if not Lump[i]:
                Ans += 1
            else:
                Ans -=1
            Lump[i] = (Lump[i]+1)%2
        print(Ans)
    return
solve()
0