結果
| 問題 | 
                            No.2089 置換の符号
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-09-30 21:40:36 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 760 bytes | 
| コンパイル時間 | 313 ms | 
| コンパイル使用メモリ | 82,572 KB | 
| 実行使用メモリ | 66,560 KB | 
| 最終ジャッジ日時 | 2024-12-22 22:47:52 | 
| 合計ジャッジ時間 | 3,408 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 WA * 15 | 
ソースコード
'''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
  while True:
    i = S.index(i)
    seen[i] = True
    if i == f:
      break
  cnt += 1
sgn = 1 if cnt % 2 == 0 else -1
print(sgn)