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

Žabe

스페셜 저지 — 출력을 사용자 정의 프로그램으로 검사하므로 여러 정답이 인정될 수 있습니다.
Platinum III 플래티넘 III
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

The Frog Regent has arranged his \(N\) frog servants in a circle, with each frog facing the back of the next one. Each frog is assigned a unique integer identifier (ID) from the set of \(1\) to \(N\). The frog arrangement is specified as a sequence of IDs. The sequence always starts with the frog with the ID \(1\). It is followed by the ID of the frog in front of it, then the ID of the next one, and so on until the ID of the last frog — the one behind the frog with ID \(1\).

A frog is considered to have made a single leap if it has jumped over the frog in front of it, swapping places with it in the process. For example, if the frogs are sequenced as "1 5 4 3 2 6" and the frog with ID \(2\) makes two leaps, the resulting sequence will be "1 2 5 4 3 6" (the frog has shifted two places forward). When the Frog Regent proclaims the number \(B\), the frog with ID \(B\) makes \(B\) leaps.

The Frog Regent wishes, using some number of proclamations, to rearrange the frogs from the starting sequence to his favourite resulting sequence. Given the starting and resulting frog sequences, write a program that will compute a sequence of proclamations needed for the Regent to rearrange the frogs into the resulting sequence. Naturally, the starting and resulting sequences will not be equal.

제약

Test cases worth 40% of total points have N not greater than 8.

입력 형식

The first line of input contains a positive integer \(N\), the number of frogs (\(3 \le N \le 100\)).

The second line of input contains a permutation of the first \(N\) positive integers, the starting frog sequence.

The third line of input contains another permutation of the first \(N\) positive integers, the resulting frog sequence.

출력 형식

Output any sequence of integers (one integer per line) that the Frog Regent can proclaim in order to rearrange the frogs into the resulting sequence.

The number of proclamations must not exceed \(100\,000\).

Note: The test data will ensure that a solution will always exist.

Scoring: Test cases worth \(40\%\) of total points have \(N\) not greater than \(8\).

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

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
입력
6
1 5 4 3 2 6
1 2 5 4 3 6
출력
2
예제 2
입력
5
1 5 3 2 4
1 5 4 2 3
출력
5
3
5
2
문제 정보

riseoj 작성

출처 COCI 2010/2011 Contest 1

평가 및 의견

Žabe

개요
출제자 난이도 Platinum III 플래티넘 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Žabe

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