RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00119

Poslozi

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
Gold I 골드 I
난이도
1.500s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

"Arrange" is a planetary popular Flash game. In "Arrange" the player is given a permutation of numbers \(1\) to \(N\) and a list of allowed swaps. He then has to perform a sequence of swaps that transforms the initial permutation back to the ordered sequence \(1, 2, 3, 4, 5, \ldots, N\).

In order to break the high score list, you need to perform the minimal amount of swaps possible. You can't do that, but you can write a program that does it for you!

제약
입력 형식

The first line of input contains two integers, \(N\) (\(1 \le N \le 12\)), the length of the initial sequence and \(M\) (\(1 \le M \le N \cdot (N - 1) / 2\)) number of allowed swaps.

The second line of input contains a permutation of number \(1\) to \(N\).

The next \(M\) lines contain descriptions of allowed swaps. If the line contains numbers \(A\) and \(B\) you are allowed to swap the \(A\)-th number with the \(B\)-th number. The input will never contain two identical swaps.

Note: the test data shall be such that the solution, not necessarily unique, will always exist.

출력 형식

In the first line of output print the minimal number of swaps, \(X\).

In the next \(X\) lines print the required swaps, in order. In each line print the index of the swap performed. Swaps are numbered increasingly as they appear in the input, starting from \(1\).

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
2 1
2 1
1 2
출력
1
1
예제 2
입력
3 2
2 1 3
1 3
2 3
출력
3
2
1
2
예제 3
입력
5 5
1 2 3 4 5
1 5
2 5
1 4
1 1
3 5
출력
0
문제 정보

riseoj 작성

출처 COCI 2009/2010 Contest 2

평가 및 의견

Poslozi

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Poslozi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8