#927
Bronze IV
MJEHURIC
시간 제한
1s
메모리 제한
32MB
제출
1
정답
1
맞힌 사람
1
정답 비율
100.0%

문제

Goran has five wooden pieces arranged in a sequence. There is a number between 1 and 5 inscribed on every piece, so that every number appears on exactly one of the five pieces. Goran wants to order the pieces to form the sequence 1, 2, 3, 4, 5 and does it like this: 1. If the number on the first piece is greater than the number on the second piece, swap them. 2. If the number on the second piece is greater than the number on the third piece, swap them. 3. If the number on the third piece is greater than the number on the fourth piece, swap them. 4. If the number on the fourth piece is greater than the number on the fifth piece, swap them. 5. If the pieces don't form the sequence 1, 2, 3, 4, 5, go to step 1. Write a program that, given the initial ordering of the pieces, outputs the ordering after each swap.

입력

The first line contains five integers separated by single spaces, the ordering of the pieces. The numbers will be between 1 and 5 (inclusive) and there will be no duplicates. The initial ordering will not be 1, 2, 3, 4, 5.

출력

After any two pieces are swapped, output the ordering of the pieces, on a single line separated by spaces.

예제 입력 1

2 1 5 3 4

예제 출력 1

1 2 5 3 4
1 2 3 5 4
1 2 3 4 5

예제 입력 2

2 3 4 5 1

예제 출력 2

2 3 4 1 5
2 3 1 4 5
2 1 3 4 5
1 2 3 4 5
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
#순위사용자언어시간메모리코드 길이
9496🥇
서준
Python8ms8076KB204B
난이도 투표
Bronze IV1명 투표· 3개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
#사용자문제결과언어시간메모리코드 길이제출 시간
9496
맞았습니다
Python8ms8076KB204B2026. 07. 15. 09:56