結果
問題 | No.1888 Odd Insertion |
ユーザー | miscalc |
提出日時 | 2021-11-07 03:46:26 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 37,828 KB |
最終ジャッジ日時 | 2024-06-29 06:03:17 |
合計ジャッジ時間 | 63,740 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
10,880 KB |
testcase_01 | AC | 29 ms
11,008 KB |
testcase_02 | AC | 30 ms
10,880 KB |
testcase_03 | AC | 28 ms
11,008 KB |
testcase_04 | AC | 26 ms
10,880 KB |
testcase_05 | AC | 26 ms
11,008 KB |
testcase_06 | AC | 170 ms
31,292 KB |
testcase_07 | AC | 173 ms
31,144 KB |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 1,667 ms
36,916 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 1,679 ms
36,956 KB |
testcase_19 | AC | 1,634 ms
36,784 KB |
testcase_20 | AC | 1,769 ms
37,192 KB |
testcase_21 | AC | 1,708 ms
36,808 KB |
testcase_22 | AC | 1,640 ms
36,552 KB |
testcase_23 | AC | 1,826 ms
37,560 KB |
testcase_24 | AC | 1,779 ms
37,464 KB |
testcase_25 | AC | 1,826 ms
37,472 KB |
testcase_26 | AC | 1,930 ms
37,820 KB |
testcase_27 | AC | 1,846 ms
31,436 KB |
testcase_28 | AC | 1,592 ms
31,168 KB |
testcase_29 | AC | 1,502 ms
37,340 KB |
testcase_30 | AC | 1,616 ms
34,364 KB |
testcase_31 | AC | 1,597 ms
31,052 KB |
testcase_32 | AC | 1,941 ms
34,616 KB |
testcase_33 | AC | 1,618 ms
37,708 KB |
testcase_34 | AC | 1,659 ms
37,584 KB |
testcase_35 | AC | 1,747 ms
34,392 KB |
testcase_36 | AC | 1,789 ms
34,396 KB |
testcase_37 | AC | 1,665 ms
37,700 KB |
testcase_38 | AC | 1,708 ms
34,632 KB |
ソースコード
# ACL-for-python by shakayami # https://github.com/shakayami/ACL-for-python class fenwick_tree(): n = 1 data = [0 for i in range(n)] def __init__(self, N): self.n = N self.data = [0 for i in range(N)] def add(self, p, x): assert 0 <= p < self.n, "0<=p<n,p={0},n={1}".format(p, self.n) p += 1 while(p <= self.n): self.data[p-1] += x p += p & -p def sum(self, l, r): assert (0 <= l and l <= r and r <= self.n), "0<=l<=r<=n,l={0},r={1},n={2}".format(l, r, self.n) return self.sum0(r)-self.sum0(l) def sum0(self, r): s = 0 while(r > 0): s += self.data[r-1] r -= r & -r return s import sys n = int(input()) p = list(map(int, input().split())) for i in range(n): p[i] -= 1 q = [0] * n for i in range(n): q[p[i]] = i fw = fenwick_tree(n) x, y = [0] * n, [0] * n for i in range(n - 1): y1 = fw.sum(0, q[i]) y2 = fw.sum(0, q[i + 1]) if y1 % 2 != 0 and y2 % 2 != 0: print("No") sys.exit(0) if y2 % 2 == 0: if y1 % 2 != 0 or q[i] < q[i + 1]: q[i], q[i + 1] = q[i + 1], q[i] y1, y2 = y2, y1 x[i] = p[q[i]] y[i] = y1 fw.add(q[i], 1) x[-1] = p[q[-1]] y[-1] = fw.sum(0, q[-1]) if y[-1] % 2 != 0: print("No") sys.exit(0) print("Yes") for i in range(n): print(x[i] + 1, y[i] + 1)