{"id":383,"date":"2024-04-29T15:28:27","date_gmt":"2024-04-29T07:28:27","guid":{"rendered":"https:\/\/seanxd.com\/?p=383"},"modified":"2024-04-29T15:28:30","modified_gmt":"2024-04-29T07:28:30","slug":"zerojudge-m851","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-m851\/","title":{"rendered":"ZeroJudge M851: Sleeping in hostels"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 13181 &#8211; Sleeping in hostels<\/h4>\n\n\n\n<p class=\"\">\u5982\u540c\u4efb\u4f55\u4e00\u4f4d\u826f\u597d\u7684\u80cc\u5305\u5ba2\u6240\u77e5\uff0c\u6cbf\u8457\u9053\u8def\u627e\u5230\u7684\u9752\u5e74\u65c5\u820d\u901a\u5e38\u64c1\u6709\u5de8\u5927\u7684\u623f\u9593\uff0c\u5e8a\u92ea\u4e00\u6392\u53c8\u4e00\u6392\u7b49\u5f85\u8457\u88ab\u4f54\u64da\u3002<\/p>\n\n\n\n<p class=\"\">\u5118\u7ba1\u9019\u4e9b\u5e8a\u92ea\u66fe\u88ab\u7121\u6578\u4eba\u4f7f\u7528\uff0c\u75b2\u618a\u8b93\u6bcf\u500b\u4eba\u90fd\u4e0d\u5728\u4e4e\u8eba\u5728\u88ab\u6b72\u6708\u6467\u6b98\u7684\u5e8a\u588a\u4e0a\uff0c\u4ee5\u4fbf\u80fd\u5920\u4e00\u53e3\u6c23\u7761\u4e0a\u597d\u5e7e\u500b\u5c0f\u6642\uff0c\u70ba\u9694\u5929\u990a\u8db3\u7cbe\u795e\u3002<br>\u4e8b\u5be6\u4e0a\uff0c\u70ba\u4e86\u6700\u5927\u5316\u7372\u5f97\u826f\u597d\u7684\u591c\u9593\u7761\u7720\uff0c\u6700\u91cd\u8981\u7684\u4e0d\u662f\u5e8a\u588a\u7684\u885b\u751f\u72c0\u6cc1\uff0c\u800c\u662f<strong>\u96e2\u6700\u8fd1\u7684\u80cc\u5305\u5ba2\u7684\u8ddd\u96e2<\/strong>\u3002\u9019\u662f\u56e0\u70ba\u5728\u4f60\u65c1\u908a\u7684\u5e8a\u4e0a\u6709\u4e00\u4f4d\u964c\u751f\u4eba\u6253\u547c\u8072\uff0c\u53ef\u80fd\u6bd4\u4e00\u7fa4\u87ce\u87f2\u66f4\u80fd\u6bc0\u4e86\u4f60\u7684\u591c\u665a\u3002<br>\u7576\u4f60\u9032\u5165\u9019\u6a23\u7684\u623f\u9593\u6642\uff0c<strong>\u76ee\u6a19\u5c31\u662f\u627e\u5230\u4e00\u5f35\u5e8a\uff0c\u6700\u5927\u7a0b\u5ea6\u5730\u8207\u6700\u8fd1\u7684\u80cc\u5305\u5ba2\u4fdd\u6301\u8ddd\u96e2<\/strong> (<strong>\u5169\u5074\u90fd\u8981\u8003\u616e<\/strong>\uff09\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>\u8f38\u5165\u7531\u591a\u500b\u6e2c\u8a66\u6848\u4f8b\u7d44\u6210\uff0c\u4ee3\u8868\u65c5\u7a0b\u4e2d\u67d0\u4e00\u665a\u5e8a\u92ea\u7684\u4f54\u7528\u60c5\u6cc1\u3002<br>\u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u6392\u5e8a\uff0c\u5305\u542b\u4e00\u4e32\u7531\u300c.\u300d\u548c\u300cX\u300d\u69cb\u6210\u7684\u5e8f\u5217 (\u6700\u591a 500,000 \u500b\u5b57\u5143\uff09\u3002\u9ede (\u300c.\u300d) \u8868\u793a\u7a7a\u5e8a\uff0c\u800c\u300cX\u300d\u8868\u793a\u6709\u4eba\u4f54\u7528\u7684\u5e8a\u3002\u4fdd\u8b49<strong>\u81f3\u5c11\u6709\u4e00\u5f35\u7a7a\u5e8a\u548c\u4e00\u5f35\u88ab\u4f54\u7528\u7684\u5e8a<\/strong>\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u500b\u6e2c\u8a66\u6848\u4f8b\uff0c\u8acb\u8f38\u51fa\u4e00\u884c\uff0c<strong>\u986f\u793a\u60a8\u5728\u6240\u9078\u5e8a\u8207\u6700\u8fd1\u9130\u5e8a\u4e4b\u9593\u53ef\u80fd\u64c1\u6709\u7684\u6700\u5927\u7a7a\u5e8a\u6578\u91cf<\/strong>\u3002<\/td><\/tr><tr><td>.X.X.<br>.X\u2026X.<br>.X\u2026.X.<br>\u2026X<\/td><td>0<br>1<br>1<br>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 class=\"\"><strong>\u7b2c\u4e00\u500b\u548c\u6700\u5f8c\u4e00\u500b\u5b57\u5143\u9700\u8981\u55ae\u7368\u5224\u65b7<\/strong>\uff0c\u5176\u4ed6\u7684\u4f4d\u7f6e\u5f80\u5de6\u53f3\u5169\u908a\u627e\u4e4b\u5f8c\u53d6\u6700\u77ed\u7684\u8ddd\u96e2\u4e26\u4e14\u6bd4\u8f03\u6700\u5927\u503c\u4e26\u8f38\u51fa\u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=m851\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge M851: Sleeping in hostels<\/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;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    string str;\n    while (cin &gt;&gt; str)\n    {\n        int ans = -999;\n        for (int i = 0; i&lt;str.length(); i++)\n        {\n            if (str[i] == &#39;.&#39;)\n            {\n                if (i == 0)\n                {\n                    int right = 0;\n                    for (int j = i+1; j&lt;str.length(); j++)\n                    {\n                        if (str[j] == &#39;X&#39;) break;\n                        right++;\n                    }\n                    ans = max(ans, right);\n                }\n                else if (i == int(str.length())-1)\n                {\n                    int left = 0;\n                    for (int j = i-1; j&gt;=0; j--)\n                    {\n                        if (str[j] == &#39;X&#39;) break;\n                        left++;\n                    }\n                    ans = max(ans, left);\n                }\n                else\n                {\n                    int right = 0;\n                    for (int j = i+1; j&lt;str.length(); j++)\n                    {\n                        if (str[j] == &#39;X&#39;) break;\n                        right++;\n                    }\n                    int left = 0;\n                    for (int j = i-1; j&gt;=0; j--)\n                    {\n                        if (str[j] == &#39;X&#39;) break;\n                        left++;\n                    }\n                    int check = min(right, left);\n                    ans = max(check, ans);\n                }\n            }\n        }\n        cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge M851\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 13181 &#8211; Sleeping in hostels \u5982\u540c\u4efb\u4f55\u4e00\u4f4d\u826f\u597d\u7684\u80cc\u5305\u5ba2\u6240\u77e5 [&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":[18],"tags":[8,11,13,9],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-11","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":384,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/383\/revisions\/384"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}