{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eSomewhere deep in the Czech Technical University buildings, there are laboratories for examin-\r\ning mechanical and electrical properties of various materials. In one of yesterday\u0027s presentations,\r\nyou have seen how was one of the laboratories changed into a new multimedia lab. But there\r\nare still others, serving to their original purposes.\r\n\r\n\u003c/p\u003e\u003cp\u003eIn this task, you are to write software for a robot that handles samples in such a laboratory.\r\nImagine there are material samples lined up on a running belt. The samples have different\r\nheights, which may cause troubles to the next processing unit. To eliminate such troubles, we\r\nneed to sort the samples by their height into the ascending order.\r\n\r\n\u003c/p\u003e\u003cp\u003eReordering is done by a mechanical robot arm, which is able to pick up any number of consecutive\r\nsamples and turn them round, such that their mutual order is reversed. In other words, one\r\nrobot operation can reverse the order of samples on positions between A and B.\r\n\r\n\u003c/p\u003e\u003cp\u003eA possible way to sort the samples is to find the position of the smallest one (P_1) and reverse\r\nthe order between positions 1 and P_1, which causes the smallest sample to become first. Then\r\nwe find the second one on position P_2 and reverse the order between 2 and P_2. Then the third\r\nsample is located etc.\r\n\r\n\u003c/p\u003e\u003cp\u003e\u003c/p\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/fba0b996359da6a54cb65a0298b39251?v\u003d1714867252\" alt\u003d\"example\"\u003e\u003c/center\u003e\r\n\r\n\u003cp\u003eThe picture shows a simple example of 6 samples. The smallest one is on the 4th position,\r\ntherefore, the robot arm reverses the first 4 samples. The second smallest sample is the last one,\r\nso the next robot operation will reverse the order of five samples on positions 2-6. The third\r\nstep will be to reverse the samples 3-4, etc.\r\n\r\n\u003c/p\u003e\u003cp\u003eYour task is to find the correct sequence of reversal operations that will sort the samples using the above algorithm. If there are more samples with the same height, their mutual order must\r\nbe preserved: the one that was given first in the initial order must be placed before the others\r\nin the final order too.\r\n\r\n\r\n\u003c/p\u003e\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe input consists of several scenarios. Each scenario is described by two lines. The first line\r\ncontains one integer number N, the number of samples, 1 \u0026lt;\u003d N \u0026lt;\u003d 100 000. The second line lists\r\nexactly N space-separated positive integers, they specify the heights of individual samples and\r\ntheir initial order.\r\n\r\n\u003c/p\u003e\u003cp\u003eThe last scenario is followed by a line containing zero.\r\n\r\n\r\n\u003c/p\u003e\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each scenario, output one line with exactly N integers P_1,P_2,...P_N, separated by a space.\r\nEach P_i must be an integer (1 \u0026lt;\u003d P_i \u0026lt;\u003d N) giving the position of the i-th sample just before the\r\ni-th reversal operation.\r\n\r\n\u003c/p\u003e\u003cp\u003eNote that if a sample is already on its correct position P_i, you should output the number P_i\r\nanyway, indicating that the \"interval between P_i and P_i\" (a single sample) should be reversed.\r\n\r\n\u003c/p\u003e\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n3 4 5 1 6 2\r\n4\r\n3 3 2 1\r\n0\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 6 4 5 6 6\r\n4 2 4 4\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}