結果

問題 No.1386 Range add Simulation
ユーザー MitarushiMitarushi
提出日時 2021-02-06 00:00:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 1,703 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 129,616 KB
最終ジャッジ日時 2023-09-17 18:43:05
合計ジャッジ時間 30,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
71,212 KB
testcase_01 AC 103 ms
76,576 KB
testcase_02 AC 102 ms
76,596 KB
testcase_03 AC 103 ms
76,624 KB
testcase_04 AC 105 ms
76,760 KB
testcase_05 AC 115 ms
77,840 KB
testcase_06 AC 313 ms
105,252 KB
testcase_07 AC 286 ms
104,500 KB
testcase_08 AC 298 ms
104,648 KB
testcase_09 AC 284 ms
104,580 KB
testcase_10 AC 297 ms
105,688 KB
testcase_11 AC 434 ms
125,472 KB
testcase_12 AC 452 ms
128,392 KB
testcase_13 AC 418 ms
123,484 KB
testcase_14 AC 404 ms
123,508 KB
testcase_15 AC 423 ms
128,040 KB
testcase_16 AC 424 ms
128,140 KB
testcase_17 AC 420 ms
127,900 KB
testcase_18 AC 410 ms
125,340 KB
testcase_19 AC 409 ms
124,948 KB
testcase_20 AC 425 ms
125,528 KB
testcase_21 AC 419 ms
125,104 KB
testcase_22 AC 428 ms
129,284 KB
testcase_23 AC 432 ms
125,368 KB
testcase_24 AC 418 ms
128,180 KB
testcase_25 AC 423 ms
128,052 KB
testcase_26 AC 404 ms
127,188 KB
testcase_27 AC 425 ms
129,616 KB
testcase_28 AC 417 ms
127,532 KB
testcase_29 AC 418 ms
125,172 KB
testcase_30 AC 403 ms
123,724 KB
testcase_31 AC 377 ms
120,604 KB
testcase_32 AC 384 ms
120,556 KB
testcase_33 AC 380 ms
120,636 KB
testcase_34 AC 374 ms
120,664 KB
testcase_35 AC 70 ms
71,472 KB
testcase_36 AC 135 ms
77,876 KB
testcase_37 AC 125 ms
77,576 KB
testcase_38 AC 144 ms
77,880 KB
testcase_39 AC 138 ms
77,712 KB
testcase_40 AC 405 ms
127,736 KB
testcase_41 AC 407 ms
125,872 KB
testcase_42 AC 407 ms
127,516 KB
testcase_43 AC 406 ms
126,516 KB
testcase_44 AC 406 ms
126,412 KB
testcase_45 AC 404 ms
127,416 KB
testcase_46 AC 400 ms
126,132 KB
testcase_47 AC 399 ms
127,480 KB
testcase_48 AC 409 ms
127,448 KB
testcase_49 AC 435 ms
126,036 KB
権限があれば一括ダウンロードができます

ソースコード

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 <= 10:
    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