시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 2151 1102 1003 57.086%

문제

동혁이는 나무 조각을 5개 가지고 있다. 나무 조각에는 1부터 5까지 숫자 중 하나가 쓰여져 있다. 또, 모든 숫자는 다섯 조각 중 하나에만 쓰여 있다.

동혁이는 나무 조각을 다음과 같은 과정을 거쳐서 1, 2, 3, 4, 5 순서로 만드려고 한다.

  1. 첫 번째 조각의 수가 두 번째 수보다 크다면, 둘의 위치를 서로 바꾼다.
  2. 두 번째 조각의 수가 세 번째 수보다 크다면, 둘의 위치를 서로 바꾼다.
  3. 세 번째 조각의 수가 네 번째 수보다 크다면, 둘의 위치를 서로 바꾼다.
  4. 네 번째 조각의 수가 다섯 번째 수보다 크다면, 둘의 위치를 서로 바꾼다.
  5. 만약 순서가 1, 2, 3, 4, 5 순서가 아니라면 1 단계로 다시 간다.

처음 조각의 순서가 주어졌을 때, 위치를 바꿀 때 마다 조각의 순서를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 조각에 쓰여 있는 수가 순서대로 주어진다. 숫자는 1보다 크거나 같고, 5보다 작거나 같으며, 중복되지 않는다. 처음 순서는 1, 2, 3, 4, 5가 아니다.

출력

두 조각의 순서가 바뀔때 마다 조각의 순서를 출력한다.

예제 입력 1

2 1 5 3 4

예제 출력 1

1 2 5 3 4
1 2 3 5 4
1 2 3 4 5
W3sicHJvYmxlbV9pZCI6IjI5NDciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIwOThcdWJiMzQgXHVjODcwXHVhYzAxIiwiZGVzY3JpcHRpb24iOiI8cD5cdWIzZDlcdWQ2MDFcdWM3NzRcdWIyOTQgXHViMDk4XHViYjM0IFx1Yzg3MFx1YWMwMVx1Yzc0NCA1XHVhYzFjIFx1YWMwMFx1YzljMFx1YWNlMCBcdWM3ODhcdWIyZTQuIFx1YjA5OFx1YmIzNCBcdWM4NzBcdWFjMDFcdWM1ZDBcdWIyOTQgMVx1YmQ4MFx1Z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8bGk+SWYgdGhlIHBpZWNlcyBkb24mIzM5O3QgZm9ybSB0aGUgc2VxdWVuY2UgMSwgMiwgMywgNCwgNSwgZ28gdG8gc3RlcCAxLiZuYnNwOzxcL2xpPlxyXG48XC9vbD5cclxuXHJcbjxwPldyaXRlIGEgcHJvZ3JhbSB0aGF0LCBnaXZlbiB0aGUgaW5pdGlhbCBvcmRlcmluZyBvZiB0aGUgcGllY2VzLCBvdXRwdXRzIHRoZSBvcmRlcmluZyBhZnRlciBlYWNoIHN3YXAuJm5ic3A7PFwvcD5cclxuIiwiaW5wdXQiOiI8cD5UaGUgZmlyc3QgbGluZSBjb250YWlucyBmaXZlIGludGVnZXJzIHNlcGFyYXRlZCBieSBzaW5nbGUgc3BhY2VzLCB0aGUgb3JkZXJpbmcgb2YgdGhlIHBpZWNlcy4mbmJzcDs8XC9wPlxyXG5cclxuPHA+VGhlIG51bWJlcnMgd2lsbCBiZSBiZXR3ZWVuIDEgYW5kIDUgKGluY2x1c2l2ZSkgYW5kIHRoZXJlIHdpbGwgYmUgbm8gZHVwbGljYXRlcy4mbmJzcDs8XC9wPlxyXG5cclxuPHA+VGhlIGluaXRpYWwgb3JkZXJpbmcgd2lsbCBub3QgYmUgMSwgMiwgMywgNCwgNS4mbmJzcDs8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5BZnRlciBhbnkgdHdvIHBpZWNlcyBhcmUgc3dhcHBlZCwgb3V0cHV0IHRoZSBvcmRlcmluZyBvZiB0aGUgcGllY2VzLCBvbiBhIHNpbmdsZSBsaW5lIHNlcGFyYXRlZCBieSBzcGFjZXMuJm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Contest > Croatian Open Competition in Informatics > COCI 2008/2009 > Contest #4 1번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: jh05013