{"id":366,"date":"2013-03-25T13:39:00","date_gmt":"2013-03-25T05:39:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/270"},"modified":"2013-03-25T13:39:00","modified_gmt":"2013-03-25T05:39:00","slug":"cf_286c_main_sequence-greedy_matching_brackets","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=366","title":{"rendered":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d)"},"content":{"rendered":"<div style=\"margin:0px; padding:0px; font-family:verdana,arial,sans-serif; font-size:14px; position:relative\">\n<div id=\"content\" class=\"content-with-sidebar\" style=\"margin:1em; padding:1em 0px 0px; min-height:20em\">\n<div class=\"ttypography\" style=\"margin:0px; padding:0px; font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; line-height:21px; color:rgb(34,34,34); word-wrap:break-word\">\n<div class=\"problem-statement\" style=\"margin:0.5em; padding:0px; line-height:1.5em\">\n<div class=\"header\" style=\"margin:0px 0px 1em; padding:0px; text-align:center\">\n<div class=\"title\" style=\"margin:0px 0px 0.5em; padding:0px; font-size:21px\">C. Main Sequence<\/div>\n<div class=\"time-limit\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\ntime limit per test<\/div>\n<p>2 seconds<\/p><\/div>\n<div class=\"memory-limit\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\nmemory limit per test<\/div>\n<p>256 megabytes<\/p><\/div>\n<div class=\"input-file\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\ninput<\/div>\n<p>standard input<\/p><\/div>\n<div class=\"output-file\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\noutput<\/div>\n<p>standard output<\/p><\/div>\n<\/div>\n<div style=\"margin:0px; padding:0px\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nAs you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different types of brackets since prehistoric times.<br \/>\n A bracket type is a positive integer. The shamans define a correct bracket sequence as follows:<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\n<ul style=\"margin:0.5em 0px 0px 1em; padding:0px; list-style-position:outside; font-size:1em; line-height:1.5em\">\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\nAn empty sequence is a correct bracket sequence.<\/li>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\nIf&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>l<\/em><\/sub>}<\/span>&nbsp;and&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>k<\/em><\/sub>}<\/span>&nbsp;are<br \/>\n correct bracket sequences, then sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>l<\/em><\/sub>,\u2009<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>b<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>k<\/em><\/sub>}<\/span>&nbsp;(their<br \/>\n concatenation) also is a correct bracket sequence.<\/li>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\nIf&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>l<\/em><\/sub>}<\/span>&nbsp;\u2014<br \/>\n is a correct bracket sequence, then sequence&nbsp;<img decoding=\"async\" src=\"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png\" alt=\"\" \/>&nbsp;also is a correct bracket sequence, where&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>v<\/em><\/span>&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(<em>v<\/em>\u2009&gt;\u20090)<\/span>&nbsp;is<br \/>\n an integer.<\/li>\n<\/ul>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nFor example, sequences&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{1,\u20091,\u2009\u2009-\u20091,\u20092,\u2009\u2009-\u20092,\u2009\u2009-\u20091}<\/span>&nbsp;and&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{3,\u2009\u2009-\u20093}<\/span>&nbsp;are<br \/>\n correct bracket sequences, and&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{2,\u2009\u2009-\u20093}<\/span>&nbsp;is not.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nMoreover, after Vova became a shaman, he learned the&nbsp;<span class=\"tex-font-style-it\" style=\"font-style:italic\">most important<\/span>&nbsp;correct bracket sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub>}<\/span>,<br \/>\n consisting of&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>integers. As sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>x<\/em><\/span>&nbsp;is the most<br \/>\n important, Vova decided to encrypt it just in case.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nEncrypting consists of two sequences. The first sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub>}<\/span>&nbsp;contains<br \/>\n types of brackets, that is,&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>\u2009=\u2009|<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>|<\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">1\u2009\u2264\u2009<em>i<\/em>\u2009\u2264\u2009<em>n<\/em><\/span>).<br \/>\n The second sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>t<\/em><\/sub>}<\/span>&nbsp;contains&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>t<\/em><\/span>&nbsp;integers<br \/>\n \u2014 <strong>\u8fd9\u4e9b\u5730\u65b9\u5fc5\u987b\u53d6\u8d1f\u6570<\/strong>&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub>}<\/span>.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nUnfortunately, Vova forgot the main sequence. But he was lucky enough to keep the encryption: sequences&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub>}<\/span>&nbsp;and<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>t<\/em><\/sub>}<\/span>.<br \/>\n Help Vova restore sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>x<\/em><\/span>&nbsp;by the encryption. If there are multiple sequences that correspond to the encryption, restore any of them. If there are no<br \/>\n such sequences, you should tell so.<\/p>\n<\/div>\n<div class=\"input-specification\" style=\"margin:0px; padding:0px\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-size:16px; font-weight:bold\">\nInput<\/div>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nThe first line of the input contains integer&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">1\u2009\u2264\u2009<em>n<\/em>\u2009\u2264\u200910<sup class=\"upper-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; top:-0.5em\">6<\/sup><\/span>).<br \/>\n The second line contains&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>&nbsp;integers:&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub><\/span>&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(1\u2009\u2264\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>\u2009\u2264\u200910<sup class=\"upper-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; top:-0.5em\">9<\/sup>)<\/span>.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nThe third line contains integer&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>t<\/em><\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">0\u2009\u2264\u2009<em>t<\/em>\u2009\u2264\u2009<em>n<\/em><\/span>),<br \/>\n followed by&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>t<\/em><\/span>&nbsp;distinct integers&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>t<\/em><\/sub><\/span>&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(1\u2009\u2264\u2009<em>q<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>\u2009\u2264\u2009<em>n<\/em>)<\/span>.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nThe numbers in each line are separated by spaces.<\/p>\n<\/div>\n<div class=\"output-specification\" style=\"margin:0px 0px 1em; padding:0px\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-size:16px; font-weight:bold\">\nOutput<\/div>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nPrint a single string &quot;<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">NO<\/span>&quot; (without the quotes) if Vova is mistaken and a suitable sequence&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">{<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub>}<\/span>&nbsp;doesn't<br \/>\n exist.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.4em\">\nOtherwise, in the first line print &quot;<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">YES<\/span>&quot; (without the quotes) and in the second line print&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>&nbsp;integers&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub><\/span>&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(|<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>|\u2009=\u2009<em>p<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>;&nbsp;<em>x<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>q<\/em><\/sub><sub class=\"lower-index\" style=\"font-size:12px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>j<\/em><\/sub>\u2009&lt;\u20090)<\/span>.<br \/>\n If there are multiple sequences that correspond to the encrypting, you are allowed to print any of them.<\/p>\n<\/div>\n<div class=\"sample-tests\" style=\"margin:0px; padding:0px; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; font-size:0.9em\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; font-weight:bold\">\nSample test(s)<\/div>\n<div class=\"sample-test\" style=\"margin:0px; padding:0px\">\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">2\n1 1\n0\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">YES\n1 -1\n<\/pre>\n<\/div>\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">4\n1 1 1 1\n1 3\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">YES\n1 1 -1 -1\n<\/pre>\n<\/div>\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">3\n1 1 1\n0\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">NO\n<\/pre>\n<\/div>\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">4\n1 2 2 1\n2 3 4\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">YES\n1 2 -2 -1\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><span style=\"font-size:14px\">\u8d2a\u5fc3\uff0c\u4ece\u540e\u5411\u524d\u505a\uff0c\u5c3d\u53ef\u80fd\u53d6\u5de6\u62ec\u53f7\u3002<\/span><\/p>\n<p><span style=\"font-size:14px\"><\/span><\/p>\n<pre name=\"code\" class=\"cpp\">#include&lt;cstdio&gt;\n#include&lt;cstring&gt;\n#include&lt;cstdlib&gt;\n#include&lt;iostream&gt;\n#include&lt;functional&gt;\n#include&lt;algorithm&gt;\n#include&lt;stack&gt;\nusing namespace std;\n#define MAXN (1000000+10)\n#define MAXP (1000000000+10)\nint n,m,a[MAXN],ans[MAXN],tot;\nbool b[MAXN];\nint s[MAXN],size=0;\nint main()\n{\n\tmemset(b,0,sizeof(b));\n\tscanf(&quot;%d&quot;,&amp;n);tot=n+1;\n\tif (n%2) {printf(&quot;NOn&quot;);return 0;}\n\tfor (int i=1;i&lt;=n;i++) scanf(&quot;%d&quot;,&amp;a[i]);\n\tscanf(&quot;%d&quot;,&amp;m);\n\tfor (int i=1;i&lt;=m;i++)\n\t{\n\t\tint p;\n\t\tscanf(&quot;%d&quot;,&amp;p);\n\t\tb[p]=1;\n\t}\n\tfor (int i=n;i;i--)\n\t{\n\t\tif (size==0||s[size]!=a[i]||b[i])\n\t\t{\n\t\t\ts[++size]=a[i];ans[--tot]=-a[i];\n\t\t}\n\t\telse ans[--tot]=s[size--];\n\t}\n\tif (size) printf(&quot;NOn&quot;);\n\telse\n\t{\n\t\tprintf(&quot;YESn&quot;);\n\t\tfor (int i=1;i&lt;n;i++) printf(&quot;%d &quot;,ans[i]);printf(&quot;%dn&quot;,ans[n]);\n\t}\n\n\treturn 0;\n}<\/pre>\n<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C. Main Sequence time limit per test 2 seconds memory l [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[81,118],"class_list":["post-366","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-series","tag-greedy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nike0good.com\/?p=366\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good\" \/>\n<meta property=\"og:description\" content=\"C. Main Sequence time limit per test 2 seconds memory l [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=366\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-25T05:39:00+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d)\",\"datePublished\":\"2013-03-25T05:39:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366\"},\"wordCount\":493,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/nike0good.jp1.rpvhost.net\\\/wp-content\\\/uploads\\\/csdn\\\/other_site\\\/img_my_1364190227_9845.png\",\"keywords\":[\"\u6570\u5217\",\"\u8d2a\u5fc3\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=366#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=366\",\"name\":\"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/nike0good.jp1.rpvhost.net\\\/wp-content\\\/uploads\\\/csdn\\\/other_site\\\/img_my_1364190227_9845.png\",\"datePublished\":\"2013-03-25T05:39:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=366\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#primaryimage\",\"url\":\"http:\\\/\\\/nike0good.jp1.rpvhost.net\\\/wp-content\\\/uploads\\\/csdn\\\/other_site\\\/img_my_1364190227_9845.png\",\"contentUrl\":\"http:\\\/\\\/nike0good.jp1.rpvhost.net\\\/wp-content\\\/uploads\\\/csdn\\\/other_site\\\/img_my_1364190227_9845.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=366#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nike0good.com\/?p=366","og_locale":"zh_CN","og_type":"article","og_title":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good","og_description":"C. Main Sequence time limit per test 2 seconds memory l [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=366","og_site_name":"nike0good","article_published_time":"2013-03-25T05:39:00+00:00","og_image":[{"url":"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png","type":"","width":"","height":""}],"author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=366#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=366"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d)","datePublished":"2013-03-25T05:39:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=366"},"wordCount":493,"commentCount":0,"image":{"@id":"https:\/\/nike0good.com\/?p=366#primaryimage"},"thumbnailUrl":"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png","keywords":["\u6570\u5217","\u8d2a\u5fc3"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=366#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=366","url":"https:\/\/nike0good.com\/?p=366","name":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d) - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/nike0good.com\/?p=366#primaryimage"},"image":{"@id":"https:\/\/nike0good.com\/?p=366#primaryimage"},"thumbnailUrl":"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png","datePublished":"2013-03-25T05:39:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=366#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=366"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/nike0good.com\/?p=366#primaryimage","url":"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png","contentUrl":"http:\/\/nike0good.jp1.rpvhost.net\/wp-content\/uploads\/csdn\/other_site\/img_my_1364190227_9845.png"},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=366#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"CF 286C(Main Sequence-\u8d2a\u5fc3\u62ec\u53f7\u5339\u914d)"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=366"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/366\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}