結果
問題 | No.1209 XOR Into You |
ユーザー | NatsubiSogan |
提出日時 | 2020-08-31 18:07:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 801 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 38,860 KB |
最終ジャッジ日時 | 2024-04-28 06:09:34 |
合計ジャッジ時間 | 18,244 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
10,624 KB |
testcase_01 | AC | 31 ms
10,624 KB |
testcase_02 | AC | 30 ms
10,752 KB |
testcase_03 | AC | 31 ms
10,880 KB |
testcase_04 | AC | 101 ms
26,640 KB |
testcase_05 | AC | 102 ms
26,376 KB |
testcase_06 | AC | 170 ms
38,824 KB |
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 | AC | 324 ms
26,072 KB |
testcase_22 | AC | 476 ms
38,860 KB |
testcase_23 | AC | 475 ms
38,752 KB |
testcase_24 | AC | 471 ms
38,768 KB |
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 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 399 ms
28,112 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 474 ms
38,776 KB |
ソースコード
n = int(input()) BIT = [0] * (n + 1) def zaatu(l): l2 = sorted(set(l)) d = {l2[i]: i for i in range(len(l2))} return [d[i] for i in l] def add(i, x): while i <= n: BIT[i] += x i += i & -i def query(i): s = 0 while i > 0: s += BIT[i] i -= i & -i return s a = list(map(int, input().split())) b = list(map(int, input().split())) if a[0] != b[0] or a[-1] != b[-1]: print(-1) else: try: a2 = [a[i] ^ a[i + 1] for i in range(n - 1)] b2 = [b[i] ^ b[i + 1] for i in range(n - 1)] dic = {b2[i]: i + 1 for i in range(n - 1)} lis = [dic[i] for i in a2] ans = 0 for i in range(n - 1): ans += i - query(lis[i]) add(lis[i], 1) print(ans) except: print(-1)