結果

問題 No.1673 Lamps on a line
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-09-10 21:56:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 565 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 8,964 KB
最終ジャッジ日時 2023-09-02 17:09:30
合計ジャッジ時間 2,393 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sqlite3

n, q = map(int, input().split())
l = [0]*q
r = [0]*q
for i in range(q):
    l[i], r[i] = map(lambda v: int(v)-1, input().split())

with sqlite3.connect(':memory:') as con:
    cur = con.cursor()
    cur.execute("CREATE TABLE T (id int, light int)")
    cur.execute("INSERT INTO T VALUES " + ','.join(f"({i}, -1)" for i in range(n)))

    for i in range(q):
        cur.execute("UPDATE T SET light = light * -1 WHERE id BETWEEN ? AND ?", (l[i], r[i]))
        cur.execute("SELECT COUNT(*) FROM T WHERE light = 1")
        print(cur.fetchall()[0][0])
0