Submission #17535413
Source Code Expand
Copy
cycode = r"""# distutils: language=c++# distutils: include_dirs=/opt/ac-librarycdef extern from "<atcoder/fenwicktree>" namespace "atcoder":cdef cppclass fenwick_tree[T]:fenwick_tree(int n)void add(int p, T x)T sum(int l, int r)ctypedef long long llcdef class FenwickTree:cdef fenwick_tree[ll] *_thisptrdef __cinit__(self, int n):self._thisptr = new fenwick_tree[ll](n)cpdef void add(self, int p, ll x):self._thisptr.add(p, x)cpdef ll sum(self, int l, int r):return self._thisptr.sum(l, r)"""import os, sysif sys.argv[-1] == 'ONLINE_JUDGE':open('fenwick_tree.pyx', 'w').write(cycode)
cycode = r""" # distutils: language=c++ # distutils: include_dirs=/opt/ac-library cdef extern from "<atcoder/fenwicktree>" namespace "atcoder": cdef cppclass fenwick_tree[T]: fenwick_tree(int n) void add(int p, T x) T sum(int l, int r) ctypedef long long ll cdef class FenwickTree: cdef fenwick_tree[ll] *_thisptr def __cinit__(self, int n): self._thisptr = new fenwick_tree[ll](n) cpdef void add(self, int p, ll x): self._thisptr.add(p, x) cpdef ll sum(self, int l, int r): return self._thisptr.sum(l, r) """ import os, sys if sys.argv[-1] == 'ONLINE_JUDGE': open('fenwick_tree.pyx', 'w').write(cycode) os.system('cythonize -i -3 fenwick_tree.pyx') from fenwick_tree import FenwickTree n, q = map(int, input().split()) ft = FenwickTree(n) for i, a in enumerate(map(int, input().split())): ft.add(i, a) res = [] for _ in range(q): t, u, v = map(int, input().split()) if t == 0: ft.add(u, v) else: res.append(ft.sum(u, v)) print('\n'.join(map(str, res)))
Submission Info
Submission Time | |
---|---|
Task | B - Fenwick Tree |
User | c_r_5 |
Language | Python (3.8.2) |
Score | 100 |
Code Size | 1061 Byte |
Status | AC |
Exec Time | 1287 ms |
Memory | 55332 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00 |
All | example_00, max_random_00, max_random_01, max_random_02, max_random_03, max_random_04, random_00, random_01, random_02, random_03, random_04, small_00, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00 | AC | 29 ms | 10200 KB |
max_random_00 | AC | 1283 ms | 55320 KB |
max_random_01 | AC | 1271 ms | 55320 KB |
max_random_02 | AC | 1284 ms | 55332 KB |
max_random_03 | AC | 1278 ms | 55260 KB |
max_random_04 | AC | 1287 ms | 55084 KB |
random_00 | AC | 1034 ms | 44596 KB |
random_01 | AC | 1086 ms | 50776 KB |
random_02 | AC | 839 ms | 34688 KB |
random_03 | AC | 233 ms | 47820 KB |
random_04 | AC | 336 ms | 34760 KB |
small_00 | AC | 29 ms | 10188 KB |
small_01 | AC | 25 ms | 10096 KB |
small_02 | AC | 25 ms | 9988 KB |
small_03 | AC | 22 ms | 10096 KB |
small_04 | AC | 28 ms | 10108 KB |
small_05 | AC | 28 ms | 10112 KB |
small_06 | AC | 27 ms | 9984 KB |
small_07 | AC | 28 ms | 10208 KB |
small_08 | AC | 21 ms | 10084 KB |
small_09 | AC | 21 ms | 10188 KB |