{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"https://i0.wp.com/i.imgur.com/pxRRu.jpg?resize\u003d500%2C327\u0026quality\u003d100\"\u003e\u003cbr\u003e\n\u003cp\u003eThere is a famous railway station in The Island of Sodor that is incredibly hilly. The station\nwas built in last century. Unfortunately, funds were extremely limited that time. It was possible to\nestablish only a surface track. Moreover, it turned out that the station could be only a dead-end one\n(see picture) and due to lack of available space it could have only one track.\u003c/p\u003e\n\n\u003cimg src\u003d\"https://media.cheggcdn.com/media/37c/37c4f9e3-dc69-4875-a3fd-669623c7f4ea/php7LIBKV.png\"\u003e\n\n\u003cp\u003eThe local tradition is that every train arriving from the direction A continues in the direction\nB with coaches reorganized in some way. Assume that the train arriving from the direction A has\n\u003ci\u003eN\u003c/i\u003e ≤ 1000 coaches numbered in increasing order 1, 2, . . . , \u003ci\u003eN\u003c/i\u003e . The chief for train reorganizations must\nknow whether it is possible to marshal coaches continuing in the direction B so that their order will\nbe \u003ci\u003ea\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003e1\u003c/i\u003e\u003c/sub\u003e,a\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003e2\u003c/i\u003e\u003c/sub\u003e, . . . , a\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003eN\u003c/i\u003e\u003c/sub\u003e\u003c/i\u003e. Help him and write a program that decides whether it is possible to get the required\norder of coaches. You can assume that single coaches can be disconnected from the train before they\nenter the station and that they can move themselves until they are on the track in the direction B. You\ncan also suppose that at any time there can be located as many coaches as necessary in the station.\nBut once a coach has entered the station it cannot return to the track in the direction A and also once\nit has left the station in the direction B it cannot return back to the station.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input file consists of blocks of lines. Each block except the last describes one train and possibly\nmore requirements for its reorganization. In the first line of the block there is the integer \u003ci\u003eN\u003c/i\u003e described\nabove. In each of the next lines of the block there is a permutation of 1, 2, . . . , \u003ci\u003eN\u003c/i\u003e . The last line of the\nblock contains just ‘0’.\u003cbr\u003e\nThe last block consists of just one line containing ‘0’."}},{"title":"Output","value":{"format":"HTML","content":"The output file contains the lines corresponding to the lines with permutations in the input file. A line\nof the output file contains ‘Yes’ if it is possible to marshal the coaches in the order required on the\ncorresponding line of the input file. Otherwise it contains ‘No’. In addition, there is one empty line after\nthe lines corresponding to one block of the input file. There is no line in the output file corresponding\nto the last “null” block of the input file."}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003e5\n1 2 3 4 5\n5 4 1 2 3\n0\n6\n6 5 4 3 2 1\n0\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\nNo\n\nYes\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"https://s2.dmcdn.net/v/NJWRR1QjXN675vqLm/x1080\"\u003e\u003cbr\u003e\n\u003cimg src\u003d\"https://i.imgflip.com/46r09u.jpg\"\u003e"}}]}