結果
| 問題 | 
                            No.1386 Range add Simulation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-02-07 18:28:00 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,707 bytes | 
| コンパイル時間 | 525 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 385,952 KB | 
| 最終ジャッジ日時 | 2024-07-04 13:15:23 | 
| 合計ジャッジ時間 | 6,526 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 5 TLE * 1 -- * 43 | 
ソースコード
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()