{"id":640,"date":"2024-07-06T09:00:00","date_gmt":"2024-07-06T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=640"},"modified":"2024-07-06T13:01:58","modified_gmt":"2024-07-06T05:01:58","slug":"zerojudge-f072","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-f072\/","title":{"rendered":"ZeroJudge F072: Garden"},"content":{"rendered":"\n\n\n<p>\u5c0f\u660e\u642c\u5230\u4e00\u500b\u65b0\u5bb6\uff0c\u65b0\u5bb6\u8ddf\u820a\u5bb6\u5f88\u4e0d\u4e00\u6a23\u7684\u5730\u65b9\u5c31\u662f\u65b0\u5bb6\u7684\u5f8c\u65b9\u591a\u4e86\u4e00\u5927\u584a\u82b1\u5703\uff0c\u5c0f\u660e\u6c7a\u5b9a\u8981\u5e6b\u4ed6\u7684\u82b1\u5703\u653e\u4e0a\u4e00\u4e9b\u67f5\u6b04\u4ee5\u53ca\u7a2e\u4e0a\u4e00\u4e9b\u82b1\u3002\u70ba\u4e86\u7f8e\u89c0\u6027\u8cea\uff0c\u5c0f\u660e\u6c7a\u5b9a<strong>\u53ea\u5728\u67f5\u6b04\u8207\u67f5\u6b04\u4e4b\u9593\u7684\u7a7a\u5730\u7a2e\u82b1<\/strong>\u3002\u4f46\u662f\u4e8b\u60c5\u6c92\u6709\u9019\u9ebc\u5bb9\u6613\uff0c\u5c0f\u660e\u767c\u73fe\u67d0\u4e9b\u4f4d\u7f6e\u6703\u51fa\u73fe\u5bb3\u87f2\uff0c<strong>\u7576\u67d0\u4e00\u584a\u5730\u51fa\u73fe\u5bb3\u87f2\u6642\uff0c\u90a3\u4e00\u584a\u5730\u8207\u5de6\u53f3\u76f8\u9130\u7684\u5169\u584a\u5730\u7686\u7121\u6cd5\u7a2e\u82b1<\/strong>\u3002<\/p>\n\n\n\n<p>\u5c0f\u660e\u6c7a\u5b9a\u7528\u6578\u5b57\u7d00\u9304\u82b1\u5703\u7684\u60c5\u6cc1\uff0c\u6578\u5b57 <strong>0 \u4ee3\u8868\u4e00\u584a\u7a7a\u5730<\/strong>\uff0c\u6578\u5b57 <strong>1 \u4ee3\u8868\u8a72\u5730\u653e\u7f6e\u67f5\u6b04<\/strong>\uff0c\u6578\u5b57 <strong>9 \u4ee3\u8868\u7684\u662f\u8a72\u5730\u6709\u5bb3\u87f2<\/strong>\u3002\u5c0f\u660e\u60f3\u8981\u8a08\u7b97\u4ed6\u6700\u591a\u53ef\u4ee5\u7a2e\u4e0b\u5e7e\u6735\u82b1\uff0c\u597d\u8b93\u4ed6\u53bb\u82b1\u5e97\u8cb7\u7a2e\u5b50\u4f86\u7a2e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u7b2c\u4e00\u884c\u6709\u4e00\u500b\u6574\u6578 N (1 \u2264 N \u2264 25\uff09\uff0c\u4ee3\u8868\u5c0f\u660e\u7684\u82b1\u5703\u6709\u5e7e\u584a\u5730 (\u82b1\u5712\u5f62\u72c0\u70ba\u4e00\u76f4\u7dda\uff09\uff0c\u63a5\u8457\u7b2c\u4e8c\u884c\u6703\u5e36\u6709 N \u500b\u6578\u5b57\uff0c\u53ea\u6703\u51fa\u73fe 0 \u6216 1 \u6216 9 \u4e09\u500b\u6578\u5b57\u3002<\/td><td>\u8acb\u8f38\u51fa\u5c0f\u660e\u6700\u591a\u53ef\u4ee5\u7a2e\u4e0b\u591a\u5c11\u82b1\u3002<\/td><\/tr><tr><td>5<br>1 0 0 0 1<\/td><td>3<\/td><\/tr><tr><td>10<br>0 1 0 1 0 1 0 0 1 0<\/td><td>4<\/td><\/tr><tr><td>13<br>0 1 0 9 1 0 1 0 9 0 0 1 0<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u8a2d\u5b9a\u4e00\u500b count \u8b8a\u6578\u9810\u8a2d\u70ba 0\uff0c\u4ee3\u8868\u6709\u6c92\u6709\u9047\u5230\u67f5\u6b04\u4e86\uff0c\u4e26\u4e14\u9810\u8a2d\u4e00\u500b zero \u4ee3\u8868 0 \u51fa\u73fe\u7684\u6b21\u6578\u3002\u5982\u679c\u4eca\u5929\u9047\u5230 0 \u4e86\u4f46\u662f count \u70ba 1\uff0c\u4ee3\u8868\u6c92\u6709\u67f5\u6b04\u6240\u4ee5\u9019\u88e1\u7684 0 \u90fd\u4e0d\u7b97\u3002\u5982\u679c\u9047\u5230\u67f5\u6b04\u6642\u5c31\u5c07 count \u8b8a\u6210 1\uff0c\u7576 count \u662f 1 \u6642\uff0c\u82b1\u7684\u6578\u91cf\u5c31\u53ef\u4ee5\u88ab\u8a18\u9304\u5728 zero \u4e2d\u3002\u6bcf\u6b21\u9047\u5230\u67f5\u6b04\u6642\uff0c\u5c31\u5c07\u76ee\u524d\u7684 zero \u52a0\u5230\u7b54\u6848\u4e2d\uff0c\u4e26\u4e14\u5c07 zero \u6b78\u96f6\u3002<\/p>\n\n\n\n<p>\u7576\u9047\u5230\u82b1\u6642\u9700\u8981\u5224\u65b7\u524d\u5f8c\u662f\u5426\u6709\u5bb3\u87f2\uff0c\u5982\u679c\u6709\u7684\u8a71\u5c31\u4e0d\u80fd\u5c07 zero++\u3002\u5224\u65b7\u6642\u9700\u8981\u6ce8\u610f\u7b2c\u4e00\u500b\u548c\u6700\u5f8c\u4e00\u500b\u4f4d\u7f6e\u53ea\u9700\u8981\u5224\u65b7\u4e00\u904d\u662f\u5426\u6709\u5bb3\u87f2\u907f\u514d\u9020\u6210\u8a18\u61b6\u9ad4\u5340\u6bb5\u932f\u8aa4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=f072\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F072: \u5bb6\u88e1\u7684\u5f8c\u82b1\u5712 (Garden)<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, count = 0, zero = 0, ans = 0;\n    cin &gt;&gt; N;\n    vector&lt;int&gt;num;\n    for (int i = 0; i&lt;N; i++) {\n        int tmp;\n        cin &gt;&gt; tmp;\n        num.push_back(tmp);\n    }\n    for (int i = 0; i&lt;N; i++) {\n        if (num[i] == 0) {\n            if (count == 0) continue;\n            if (i == 0) {\n                if (num[i+1] != 9) zero++;\n                continue;\n            }\n            if (i == N-1) {\n                if (num[i-1] != 9) zero++;\n                continue;\n            }\n            if (num[i+1] != 9 && num[i-1] != 9) zero++;\n            continue;\n        }\n        if (num[i] == 1) {\n            count++;\n            ans += zero;\n            zero = 0;\n        }\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge F072\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u660e\u642c\u5230\u4e00\u500b\u65b0\u5bb6\uff0c\u65b0\u5bb6\u8ddf\u820a\u5bb6\u5f88\u4e0d\u4e00\u6a23\u7684\u5730\u65b9\u5c31\u662f\u65b0\u5bb6\u7684\u5f8c\u65b9\u591a\u4e86\u4e00\u5927\u584a\u82b1\u5703\uff0c\u5c0f\u660e\u6c7a\u5b9a\u8981\u5e6b\u4ed6\u7684\u82b1\u5703\u653e\u4e0a\u4e00\u4e9b\u67f5\u6b04\u4ee5\u53ca\u7a2e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[6],"tags":[20,8,9],"class_list":["post-640","post","type-post","status-publish","format-standard","hentry","category-6","tag-20","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"predecessor-version":[{"id":1054,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/640\/revisions\/1054"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}