{"id":156,"date":"2024-04-26T15:39:47","date_gmt":"2024-04-26T07:39:47","guid":{"rendered":"https:\/\/seanxd.com\/?p=156"},"modified":"2024-04-26T15:39:49","modified_gmt":"2024-04-26T07:39:49","slug":"zerojudge-m932","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-m932\/","title":{"rendered":"ZeroJudge M932: Observing Bees"},"content":{"rendered":"\n<p class=\"\">\u871c\u8702 Bob \u5728\u4e00\u500b\u5927\u5c0f\u662f\u00a0M\uff0aN\u00a0\u7684\u8702\u5de2 (\u898b\u4e0b\u5716\uff09\uff0c\u4e26\u4e14\u6bcf\u500b\u8702\u5de2\u683c\u4e0a\u6703\u6709\u4e00\u500b\u4ee3\u8868\u5b57\u6bcd (\u5927\u6216\u5c0f\u5beb\u82f1\u6587\u5b57\u6bcd)\u3002<\/p>\n\n\n\n<p class=\"\">Bob \u4e00\u958b\u59cb\u5728\u8702\u5de2\u5de6\u4e0b\u89d2\uff0c\u884c\u8d70\u65b9\u5411\u5b9a\u7fa9\u5982\u5716\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">0 \u662f\u5f80\u53f3\u4e0a<\/li>\n\n\n\n<li class=\"\">1 \u662f\u5f80\u53f3\u908a<\/li>\n\n\n\n<li class=\"\">2 \u662f\u5f80\u53f3\u4e0b<\/li>\n\n\n\n<li class=\"\">3 \u662f\u5f80\u5de6\u4e0b<\/li>\n\n\n\n<li class=\"\">4 \u662f\u5f80\u5de6\u908a<\/li>\n\n\n\n<li class=\"\">5 \u662f\u5f80\u5de6\u4e0a<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized nfd-wb-animate nfd-wb-zoom-in-short\"><img decoding=\"async\" width=\"1024\" height=\"814\" loading=\"lazy\" src=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation-1024x814.png\" alt=\"ZeroJudge M932: \u871c\u8702\u89c0\u5bdf\n\u8702\u5de2\u65b9\u5411\u5b9a\u7fa9\u5716\" class=\"wp-image-157\" style=\"width:301px;height:auto\" srcset=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation-1024x814.png 1024w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation-300x239.png 300w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation-768x611.png 768w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation-1536x1221.png 1536w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Bee-Observation.png 1806w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"\">\u8f38\u5165\u6bcf\u6b65\u79fb\u52d5\u7684\u65b9\u5411\uff0c\u8acb\u8f38\u51fa<strong>\u7d93\u904e\u7684\u8def\u5f91\u6bcf\u683c\u7684\u4ee3\u8868\u5b57\u6bcd<\/strong>\uff0c\u4ee5\u53ca<strong>\u7d93\u904e\u5b57\u5143\u7684\u7a2e\u985e\u6578<\/strong>\uff08\u5927\u5c0f\u5beb\u76f8\u7570\uff09\uff0c\u82e5\u7d93\u904e\u6642<strong>\u78b0\u5230\u7246\u58c1\u8a72\u884c\u52d5\u6703\u505c\u5728\u539f\u5730<\/strong>\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 nfd-delay-50\"><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\u5305\u542b\u4e09\u500b\u6574\u6578 M\u3001N\u3001K (1 &lt;= M, N &lt;= 20\u30011 &lt;= K &lt;= 100)\uff0c\u8868\u793a<strong>\u8702\u5de2\u7684\u5927\u5c0f\u662f M\uff0aN<\/strong>\uff0cBob \u7684\u884c\u8d70<strong>\u8def\u5f91\u6709 K \u6b65<\/strong>\u3002<br>\u63a5\u4e0b\u4f86\u7684 M \u884c\uff0c\u6bcf\u884c\u5305\u542b N \u500b\u5b57\u6bcd (\u5927\u5c0f\u5beb\u82f1\u6587\u5b57\u6bcd)\uff0c\u4ee3\u8868\u8702\u5de2\u7684\u72c0\u614b\u3002<br>\u6700\u5f8c\u4e00\u884c\u5305\u542b K \u500b\u6574\u6578\uff0c\u8868\u793a Bob \u7684\u79fb\u52d5\u8def\u5f91\u65b9\u5411\u3002<\/td><td>\u8f38\u51fa\u5305\u542b\u5169\u500b\u90e8\u5206 (\u5404\u4e00\u884c)\uff1a<br>1. \u7531 Bob \u6bcf\u6b65\u7d93\u904e\u7684<strong>\u6bcf\u683c\u4ee3\u8868\u5b57\u6bcd\u6240\u7d44\u6210\u7684\u5b57\u4e32<\/strong>\u3002<br>2. <strong>\u7d93\u904e\u5b57\u5143\u7684\u7a2e\u985e\u6578<\/strong>\uff08\u5927\u5c0f\u5beb\u8996\u70ba\u76f8\u7570\uff09\uff0c\u7528\u4e00\u500b\u6574\u6578\u8868\u793a\u3002<\/td><\/tr><tr><td>2  4  5<br>TyuI<br>ABaB<br>0  1  2  3  0<\/td><td>Tyaau<br>4<\/td><\/tr><tr><td>4  6  11<br>rMmnis<br>LRveEX<br>ZexDoc<br>HAdbHA<br>0  1  5  1  1  0  3  0  0  1  0<\/td><td>ZeLRvmvmmnn<br>7<\/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=\"\">\u672c\u984c\u6bd4\u8f03\u8907\u96dc\u7684\u5730\u65b9\u662f\u56e0\u70ba\u984c\u76ee\u7684\u7d50\u69cb\u662f\u8702\u5de2\u72c0\uff0c\u4f46\u662f\u6536\u8cc7\u6599\u7684\u6642\u5019\u662f\u63a1\u6b63\u65b9\u5f62\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p class=\"\">\u4f46\u662f\u53ef\u4ee5\u7406\u89e3\u70ba\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\">\u53f3\u4e0a\u7684\u6642\u5019 x \u548c y \u503c\u7684\u8b8a\u5316\u70ba (0, -1)<\/li>\n\n\n\n<li class=\"\">\u53f3\u908a\u7684\u6642\u5019\u70ba (1, 0)<\/li>\n\n\n\n<li class=\"\">\u53f3\u4e0b\u7684\u6642\u5019\u70ba (1, 1)<\/li>\n\n\n\n<li class=\"\">\u5de6\u4e0b\u7684\u6642\u5019\u70ba (0, 1)<\/li>\n\n\n\n<li class=\"\">\u5de6\u908a\u7684\u6642\u5019\u70ba (-1, 0)<\/li>\n\n\n\n<li class=\"\">\u5de6\u4e0a\u7684\u6642\u5019\u70ba (-1, -1)<\/li>\n<\/ul>\n\n\n\n<p class=\"\">\u5982\u679c\u4e0d\u7406\u89e3\u7684\u8a71\u53ef\u4ee5\u62ff\u7bc4\u4f8b\u4e00\u7684\u8cc7\u6599\u7528\u756b\u7684\u65b9\u5f0f\u756b\u756b\u770b (\u5982\u4e0b\u5716) \u5c31\u6703\u5927\u6982\u77e5\u9053\u9019\u500b\u6982\u5ff5\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u6bcf\u6b21\u884c\u8d70\u6642\u90fd\u9700\u8981\u5224\u65b7\u9019\u6a23\u5b50\u8d70\u6703\u4e0d\u6703\u8d85\u51fa\u9663\u5217\u7684\u908a\u754c\u3002\u8f38\u51fa\u6b21\u6578\u7684\u90e8\u5206\u53ef\u4ee5\u4f7f\u7528 <strong>Map<\/strong> \u4f86\u5b58\u5df2\u7d93\u51fa\u73fe\u904e\u7684\u5b57\u5143\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized nfd-wb-animate nfd-wb-zoom-in-short nfd-delay-300\"><img decoding=\"async\" width=\"1024\" height=\"1024\" loading=\"lazy\" src=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad-1024x1024.png\" alt=\"ZeroJudge M932: \u871c\u8702\u89c0\u5bdf\n\u7bc4\u4f8b\u4e00\u89e3\u91cb\uff0d\u89e3\u984c\u601d\u8def\" class=\"wp-image-159\" style=\"width:315px;height:auto\" srcset=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad-1024x1024.png 1024w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad-300x300.png 300w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad-150x150.png 150w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad-768x768.png 768w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/04\/Social-Ad.png 1080w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=m932\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge M932: \u871c\u8702\u89c0\u5bdf<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-450\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;map&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\npair&lt;int, int&gt;rtn (int a, int b)\n{\n    pair&lt;int, int&gt;tmp;\n    tmp.first = a;\n    tmp.second = b;\n    return tmp;\n}\n\nint main() {\n    int M, N, K;\n    cin &gt;&gt; M &gt;&gt; N &gt;&gt; K;\n    cin.ignore();\n    vector&lt;string&gt;v;\n    for (int i = 0; i&lt;M; i++)\n    {\n        string tmp;\n        getline(cin, tmp);\n        v.push_back(tmp);\n    }\n    int x = 0, y = M-1;\n    map&lt;int, pair&lt;int, int&gt;&gt;MAP;\n    MAP[0] = rtn(0, -1);\n    MAP[1] = rtn(1, 0);\n    MAP[2] = rtn(1, 1);\n    MAP[3] = rtn(0, 1);\n    MAP[4] = rtn(-1, 0);\n    MAP[5] = rtn(-1, -1);\n    map&lt;char, int&gt;appear;\n    int ans = 0;\n    for (int i = 0; i&lt;K; i++)\n    {\n        int tmp;\n        cin &gt;&gt; tmp;\n        int xx = x + MAP[tmp].first, yy = y + MAP[tmp].second;\n        \/\/cout &lt;&lt; xx &lt;&lt; &quot; &quot; &lt;&lt; yy;\n        if (xx &gt;= 0 && xx &lt; N && yy &gt;= 0 && yy &lt; M)\n        {\n            x = xx;\n            y = yy;\n            char ch = v[y][x];\n            if (isalpha(ch))\n            {\n                cout &lt;&lt; ch;\n                if (appear[ch] == 0) ans++;\n                appear[ch]++;\n            }\n        }\n        else\n        {\n            char ch = v[y][x];\n            if (isalpha(ch))\n            {\n                cout &lt;&lt; ch;\n                if (appear[ch] == 0) ans++;\n                appear[ch]++;\n            }\n        }\n    }\n    cout &lt;&lt; &quot;\\n&quot; &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge M932\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u871c\u8702 Bob \u5728\u4e00\u500b\u5927\u5c0f\u662f\u00a0M\uff0aN\u00a0\u7684\u8702\u5de2 (\u898b\u4e0b\u5716\uff09\uff0c\u4e26\u4e14\u6bcf\u500b\u8702\u5de2\u683c\u4e0a\u6703\u6709\u4e00\u500b\u4ee3\u8868\u5b57\u6bcd (\u5927\u6216\u5c0f\u5beb\u82f1\u6587\u5b57\u6bcd) [&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":[25],"tags":[14,20,8,11,9],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-map","tag-20","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/156","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=156"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":160,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/156\/revisions\/160"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}