結果
問題 | No.2089 置換の符号 |
ユーザー |
|
提出日時 | 2022-09-30 21:43:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 772 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 66,432 KB |
最終ジャッジ日時 | 2024-12-22 22:58:33 |
合計ジャッジ時間 | 3,553 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
'''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)