結果

問題 No.2089 置換の符号
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-09-30 21:32:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 86,204 KB
実行使用メモリ 81,076 KB
最終ジャッジ日時 2023-08-24 14:51:31
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
72,652 KB
testcase_01 AC 104 ms
72,440 KB
testcase_02 AC 106 ms
72,436 KB
testcase_03 AC 105 ms
72,332 KB
testcase_04 AC 104 ms
72,444 KB
testcase_05 AC 104 ms
72,660 KB
testcase_06 AC 105 ms
72,240 KB
testcase_07 AC 103 ms
72,200 KB
testcase_08 AC 104 ms
72,204 KB
testcase_09 AC 107 ms
72,416 KB
testcase_10 AC 106 ms
72,208 KB
testcase_11 AC 105 ms
72,308 KB
testcase_12 AC 103 ms
72,460 KB
testcase_13 AC 105 ms
72,240 KB
testcase_14 AC 104 ms
72,412 KB
testcase_15 AC 104 ms
72,444 KB
testcase_16 AC 106 ms
72,308 KB
testcase_17 AC 105 ms
72,356 KB
testcase_18 AC 104 ms
72,564 KB
testcase_19 AC 104 ms
72,308 KB
testcase_20 AC 104 ms
72,428 KB
testcase_21 AC 103 ms
72,332 KB
testcase_22 AC 109 ms
72,496 KB
testcase_23 AC 113 ms
76,732 KB
testcase_24 AC 114 ms
76,704 KB
testcase_25 AC 117 ms
76,836 KB
testcase_26 AC 118 ms
77,120 KB
testcase_27 AC 139 ms
79,828 KB
testcase_28 AC 162 ms
80,792 KB
testcase_29 AC 176 ms
81,076 KB
testcase_30 AC 143 ms
80,220 KB
testcase_31 AC 146 ms
80,228 KB
testcase_32 AC 147 ms
80,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
S = list(map(int,input().split()))

def mergecount(A):
    cnt = 0
    n = len(A)
    if n>1:
        A1 = A[:n>>1]
        A2 = A[n>>1:]
        cnt += mergecount(A1)
        cnt += mergecount(A2)
        i1=0
        i2=0
        for i in range(n):
            if i2 == len(A2):
                A[i] = A1[i1]
                i1 += 1
            elif i1 == len(A1):
                A[i] = A2[i2]
                i2 += 1
            elif A1[i1] <= A2[i2]:
                A[i] = A1[i1]
                i1 += 1
            else:
                A[i] = A2[i2]
                i2 += 1
                cnt += n//2 - i1
    return cnt
if mergecount(S)%2:
    print(-1)
else:
    print(1)
0