結果

問題 No.1386 Range add Simulation
ユーザー MitarushiMitarushi
提出日時 2021-02-05 23:53:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,696 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 84,588 KB
実行使用メモリ 133,460 KB
最終ジャッジ日時 2023-09-17 18:45:02
合計ジャッジ時間 41,287 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
70,856 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 77 ms
71,020 KB
testcase_36 AC 152 ms
77,264 KB
testcase_37 AC 131 ms
77,084 KB
testcase_38 AC 152 ms
77,680 KB
testcase_39 AC 145 ms
77,584 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます

ソースコード

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

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