{"id":2295,"date":"2023-02-07T11:47:33","date_gmt":"2023-02-07T03:47:33","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2295"},"modified":"2023-02-07T14:30:14","modified_gmt":"2023-02-07T06:30:14","slug":"the-1st-universal-cup-stage-0-nanjing","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/the-1st-universal-cup-stage-0-nanjing\/","title":{"rendered":"The 1st Universal Cup, Stage 0, Nanjing"},"content":{"rendered":"<h2>Problem G. Inscryption<\/h2>\n<p>\u5176\u5b9e\u5c31\u662f\u62ec\u53f7\u5e8f\u5217\u3002\u3002\u9996\u5148\u8003\u8651\u662f\u5426\u6709\u89e3\uff0c\u90a3\u4e48\u80af\u5b9a\u5f85\u5b9a\u4f4d\u7f6e\u90fd\u586b <code>'('<\/code>\u3002<br \/>\n\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u4fdd\u8bc1\u5408\u6cd5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c3d\u53ef\u80fd\u591a\u7684\u5c06\u5f85\u5b9a\u4f4d\u7f6e\u586b\u6210 <code>')'<\/code>\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u80af\u5b9a\u5c3d\u53ef\u80fd\u9009\u4e00\u6bb5\u540e\u7f00\u53bb\u586b\u66f4\u4f18\u3002<br \/>\n\u4e0a\u9762\u7684\u89c2\u5bdf\u5df2\u7ecf\u8db3\u591f\u5199\u4e00\u4e2a\u57fa\u4e8e\u4e8c\u5206\u7b54\u6848\u7684\u89e3\u4e86\uff0c\u4e0d\u8fc7\u6211\u4eec\u53ef\u4ee5\u505a\u7684\u66f4\u597d\u3002\u3002\u3002<\/p>\n<p>\u5bf9\u4e8e\u6bcf\u4e2a\u5f85\u5b9a\u5e8f\u5217\uff0c\u6211\u4eec\u90fd\u8d2a\u5fc3\u7684\u9996\u5148\u5c06\u5176\u8bbe\u7f6e\u6210 &#8216;)&#8217;\uff0c\u518d\u4e4b\u540e\u9047\u5230\u4e0d\u5408\u6cd5\u7684\u60c5\u51b5\u65f6\uff0c\u518d\u8fdb\u884c\u8c03\u6574\uff0c<br \/>\n\u800c\u8fd9\u53ea\u9700\u8981\u8bb0\u5f55\u6211\u4eec\u524d\u9762\u6709\u591a\u5c11\u5f85\u5b9a\u7684\u4f4d\u7f6e\u88ab\u586b\u6210 <code>')'<\/code> \u5373\u53ef\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = int(1e6) + 9;\r\nint a&#x5B;N];\r\nint n;\r\n\r\nbool ok() {\r\n    int p = 1, q = 1, o = 0; REP(i, n) {\r\n        if (a&#x5B;i] == 1) {\r\n            ++p; ++q;\r\n        } else if (a&#x5B;i] == -1) {\r\n            if (q &gt; 1) {\r\n                --q;\r\n            } else if (o) {\r\n                --o; ++p; ++q;\r\n            } else {\r\n                return 0;\r\n            }\r\n        } else {\r\n            if (q &gt; 1) {\r\n                --q; ++o;\r\n            } else {\r\n                ++p; ++q;\r\n            }\r\n        }\r\n    }\r\n\r\n    int d = __gcd(p, q); p \/= d; q \/= d;\r\n    printf(&quot;%d %d\\n&quot;, p, q);\r\n    return 1;\r\n}\r\n\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n     freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n\r\n    Rush {\r\n        RD(n); REP(i, n) RD(a&#x5B;i]);\r\n        if (!ok()) puts(&quot;-1&quot;);\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem G. Inscryption \u5176\u5b9e\u5c31\u662f\u62ec\u53f7\u5e8f\u5217\u3002\u3002\u9996\u5148\u8003\u8651\u662f\u5426\u6709\u89e3\uff0c\u90a3\u4e48\u80af\u5b9a\u5f85\u5b9a\u4f4d\u7f6e\u90fd\u586b &#8216;(&#8216;\u3002 \u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u4fdd\u8bc1\u5408\u6cd5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c3d\u53ef\u80fd\u591a\u7684\u5c06\u5f85\u5b9a\u4f4d\u7f6e\u586b\u6210 &#8216;)&#8217;\u3002\u3002\u90a3\u4e48\u8fd9\u4e2a\u80af\u5b9a\u5c3d\u53ef\u80fd\u9009\u4e00\u6bb5\u540e\u7f00\u53bb\u586b\u66f4\u4f18\u3002 \u4e0a\u9762\u7684\u89c2\u5bdf\u5df2\u7ecf\u8db3\u591f\u5199\u4e00\u4e2a\u57fa\u4e8e\u4e8c\u5206\u7b54\u6848\u7684\u89e3\u4e86\uff0c\u4e0d\u8fc7\u6211\u4eec\u53ef\u4ee5\u505a\u7684\u66f4\u597d\u3002\u3002\u3002 \u5bf9\u4e8e\u6bcf\u4e2a\u5f85\u5b9a\u5e8f\u5217\uff0c\u6211\u4eec\u90fd\u8d2a\u5fc3\u7684\u9996\u5148\u5c06\u5176\u8bbe\u7f6e\u6210 &#8216;)&#8217;\uff0c\u518d\u4e4b\u540e\u9047\u5230\u4e0d\u5408\u6cd5\u7684\u60c5\u51b5\u65f6\uff0c\u518d\u8fdb\u884c\u8c03\u6574\uff0c \u800c\u8fd9\u53ea\u9700\u8981\u8bb0\u5f55\u6211\u4eec\u524d\u9762\u6709\u591a\u5c11\u5f85\u5b9a\u7684\u4f4d\u7f6e\u88ab\u586b\u6210 &#8216;)&#8217; \u5373\u53ef\u3002 const int N = int(1e6) + 9; int a&#x5B;N]; int n; bool ok() { int p = 1, q = 1, o = 0; REP(i, n) { if (a&#x5B;i] == 1) { ++p; ++q; } else if (a&#x5B;i] == -1) { if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-2295","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-B1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=2295"}],"version-history":[{"count":4,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2295\/revisions"}],"predecessor-version":[{"id":2299,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2295\/revisions\/2299"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}