結果
問題 | No.1386 Range add Simulation |
ユーザー |
|
提出日時 | 2021-02-06 00:00:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 453 ms / 2,000 ms |
コード長 | 1,703 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 125,996 KB |
最終ジャッジ日時 | 2024-07-04 13:11:01 |
合計ジャッジ時間 | 29,732 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 49 |
ソースコード
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()