結果

問題 No.2089 置換の符号
ユーザー titan23titan23
提出日時 2022-09-30 21:43:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 78,416 KB
最終ジャッジ日時 2023-08-24 15:09:40
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
73,124 KB
testcase_01 AC 111 ms
73,124 KB
testcase_02 AC 116 ms
72,904 KB
testcase_03 AC 115 ms
72,940 KB
testcase_04 AC 111 ms
73,140 KB
testcase_05 AC 111 ms
73,132 KB
testcase_06 AC 111 ms
73,052 KB
testcase_07 AC 110 ms
73,260 KB
testcase_08 AC 113 ms
73,080 KB
testcase_09 AC 111 ms
72,904 KB
testcase_10 AC 111 ms
72,932 KB
testcase_11 AC 111 ms
72,960 KB
testcase_12 AC 111 ms
72,912 KB
testcase_13 AC 112 ms
73,048 KB
testcase_14 AC 110 ms
72,996 KB
testcase_15 AC 113 ms
73,124 KB
testcase_16 AC 113 ms
73,112 KB
testcase_17 AC 114 ms
73,324 KB
testcase_18 AC 112 ms
73,072 KB
testcase_19 AC 112 ms
73,128 KB
testcase_20 AC 113 ms
73,132 KB
testcase_21 AC 114 ms
72,928 KB
testcase_22 AC 112 ms
73,452 KB
testcase_23 AC 112 ms
72,908 KB
testcase_24 AC 112 ms
73,116 KB
testcase_25 AC 115 ms
72,996 KB
testcase_26 AC 113 ms
72,904 KB
testcase_27 AC 125 ms
78,188 KB
testcase_28 AC 161 ms
78,272 KB
testcase_29 AC 186 ms
78,208 KB
testcase_30 AC 188 ms
78,072 KB
testcase_31 AC 184 ms
78,416 KB
testcase_32 AC 186 ms
78,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''input

'''
import sys
import math
from bisect import bisect_right, bisect_left
from itertools import *
from collections import *
from heapq import heapify, heappush, heappop
import random
inf = float('inf')
# mod = 1000000007
# mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
def error(*args, sep=' ', end='\n'):
  print(*args, sep=sep, end=end, file=sys.stderr)
# sys.setrecursionlimit(10**6)

#  -----------------------  #

n = int(input())
S = list(map(int, input().split()))
for i in range(n):
  S[i] -= 1
seen = [False] * n
cnt = 0
for i in range(n):
  if seen[i]:
    continue
  seen[i] = True
  f = i
  tmp = 0
  while True:
    i = S.index(i)
    seen[i] = True
    tmp += 1
    if i == f:
      break
  cnt += tmp-1

sgn = (-1) ** cnt
print(sgn)
0