목차

스왑 스왑

ps
링크acmicpc.net/…
출처BOJ
문제 번호34728
문제명스왑 스왑
레벨골드 2
분류

불변성

시간복잡도O(n)
인풋사이즈n<=2000
사용한 언어Python 3.13
제출기록32412KB / 36ms
최고기록36ms
해결날짜2025/11/13

풀이

코드

"""Solution code for "BOJ 34728. 스왑 스왑".

- Problem link: https://www.acmicpc.net/problem/34728
- Solution link: http://www.teferi.net/ps/problems/boj/34728

Tags: [parity of permutation]
"""

import sys
from teflib import permcycle


def main():
    _N = int(sys.stdin.readline())
    a = [int(x) - 1 for x in sys.stdin.readline().split()]
    print('Yes' if permcycle.sign_of_permutation(a) == 1 else 'No')


if __name__ == '__main__':
    main()