結果

問題 No.1386 Range add Simulation
ユーザー MitarushiMitarushi
提出日時 2021-02-07 18:28:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,707 bytes
コンパイル時間 1,026 ms
コンパイル使用メモリ 85,824 KB
実行使用メモリ 388,848 KB
最終ジャッジ日時 2023-09-17 18:50:31
合計ジャッジ時間 6,732 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,836 KB
testcase_01 AC 126 ms
78,728 KB
testcase_02 AC 125 ms
78,364 KB
testcase_03 AC 138 ms
78,548 KB
testcase_04 AC 126 ms
78,252 KB
testcase_05 AC 132 ms
79,208 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int, input().split())

print_cache = []


def print_c(*args):
    print_cache.append(args)


def flush():
    print(len(print_cache))
    for args in print_cache:
        print(*args)


def doubling(x, i):
    flag = False
    t = True
    if x < 0:
        x = abs(x)
        t = False
    for j in range(x.bit_length())[::-1]:
        if flag:
            print_c(3, i+1, i+1)
        else:
            flag = True
        if (x >> j) & 1 == 1:
            if t:
                print_c(1, i+1)
            else:
                print_c(2, i+1)


if n <= 100000:
    a = [0] * n
    for _ in range(q):
        c, s = map(int, input().split())
        s -= 1
        if c == 1:
            for j in range(s, n):
                a[j] += (j-s+1)**2
        else:
            for j in range(s+1):
                a[j] += (s-j+1)**2
    for i in range(n):
        doubling(a[i], i)
else:
    a = [0] * n
    b = [0] * 5
    for _ in range(q):
        c, s = map(int, input().split())
        s -= 1
        if c == 1:
            a[s] += 1
            if s+1 < n:
                a[s+1] += 1

            for i in range(5):
                if s <= i:
                    b[i] += (i-s+1)**2
        else:
            if s+2 < n:
                a[s+2] -= 1
            if s+3 < n:
                a[s+3] -= 1

            for i in range(5):
                if i <= s:
                    b[i] += (s-i+1)**2

    for i in range(3):
        for j in range(i+1, 5)[::-1]:
            b[j] -= b[j-1]

    for i in range(5):
        doubling(b[i], i)
    for i in range(5, n):
        doubling(a[i], i)

    for i in range(3)[::-1]:
        for j in range(i+1, n):
            print_c(3, j+1, j)

flush()
0