{"id":508,"date":"2024-05-26T09:00:00","date_gmt":"2024-05-26T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=508"},"modified":"2024-05-06T11:09:36","modified_gmt":"2024-05-06T03:09:36","slug":"zerojudge-c833","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-c833\/","title":{"rendered":"ZeroJudge C833: 2D-Array"},"content":{"rendered":"\n\n\n<p class=\"\">\u6709\u4e00\u5ea7\u53ef\u4ee5\u8996\u70ba\u4e8c\u7dad\u7684\u65b9\u683c\u5e73\u9762\u7684\u9577\u65b9\u5f62\u57ce\u5e02\uff0c\u7531\u4e0a\u800c\u4e0b\u5171\u6709 N \u5217\uff0c\u7531\u5de6\u81f3\u53f3\u5171\u6709 M \u884c\uff0c\u7e3d\u5171\u5283\u5206\u70ba N \u00d7 M \u500b\u65b9\u683c\u3002\u9019\u500b\u57ce\u5e02\u56e0\u70ba\u6cbb\u5b89\u5f88\u5dee\uff0c\u6240\u4ee5<strong>\u6bcf\u500b\u683c\u5b50\u4e2d\u90fd\u6709\u6a5f\u6703\u51fa\u73fe\u91ce\u751f\u7684\u7529\u68cd<\/strong>\u53ef\u4ee5\u6aa2\u62fe\u4ee5\u65b9\u4fbf\u9b25\u6bc6\u3002\u4f60<strong>\u60f3\u8981\u6aa2\u4e00\u4e9b\u7529\u68cd<\/strong>\uff0c\u4f46\u4f60\u77e5\u9053\u57ce\u5e02\u7684\u5176\u4e2d\u4e00\u4e9b\u65b9\u683c\u8a2d\u6709\u8b66\u5bdf\u5c40\uff0c<strong>\u5982\u679c\u8b66\u5bdf\u5c40\u5167\u7684\u8b66\u5bdf\u5728\u9019\u500b\u65b9\u683c\u6216\u8207\u5176\u540c\u4e00\u884c\u6216\u540c\u4e00\u5217\u7684\u4efb\u4f55\u65b9\u683c\u5075\u6e2c\u5230\u6709\u4eba\u5728\u6aa2\u62fe\u7529\u68cd\uff0c\u90fd\u6703\u6beb\u4e0d\u7559\u60c5\u5730\u628a\u64bf\u62fe\u7684\u4eba\u9810\u9632\u6027\u7f88\u62bc<\/strong>\uff0c\u6240\u4ee5\u70ba\u4e86\u5b89\u5168\uff0c\u4f60\u7d55\u5c0d\u4e0d\u6703\u53bb\u90a3\u4e9b\u65b9\u683c\u6aa2\u62fe\u7529\u68cd\u3002\u4f60\u60f3\u8981\u77e5\u9053\u5728\u4e0a\u8ff0\u689d\u4ef6\u4e0b\uff0c\u4f60\u9084<strong>\u53ef\u4ee5\u53bb\u90a3\u4e9b\u65b9\u683c\u6aa2\u62fe\u7529\u68cd<\/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\"><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\u7684\u7b2c\u4e00\u5217\u4f9d\u5e8f\u70ba\u6b63\u6574\u6578N \u548c M\uff0c\u8868\u793a\u9019\u5ea7\u57ce\u5e02\u7531\u4e0a\u800c\u4e0b\u5171\u6709 N \u5217\uff0c\u7531\u5de6\u81f3\u53f3\u5171\u6709 M \u884c\uff0c\u7e3d\u5171\u5283\u5206\u70ba N \u00d7 M \u500b\u65b9\u683c\u3002<br>\u63a5\u8457\u5171\u6709 N \u5217\uff0c\u6bcf\u5217\u70ba\u4e00\u500b\u9577\u5ea6\u6070\u70ba M \u7684\u5b57\u4e32\uff0c\u6bcf\u500b\u5b57\u5143\u5247\u53ef\u80fd\u70ba\u300c\u2022\u300d\uff08ASCII \u7de8\u78bc 46\uff09\u6216\u300c\uff03\u300d\uff08ASCII \u7de8\u78bc 35\uff09\uff0c\u82e5\u5176\u4e2d\u7b2c\u5217\u7684\u7b2c j \u500b\u5b57\u5143\u70ba\u300c#\u300d\uff0c\u8868\u793a\u57ce\u5e02\u4e2d\u7b2c\u5217\u7b2c j \u884c\u7684\u65b9\u683c\u8a2d\u6709\u8b66\u5bdf\u5c40\uff0c\u5426\u5247\u8868\u793a\u6c92\u8a2d\u8b66\u5bdf\u5c40\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8a72\u5217\u4e0d\u6703\u6709\u5176\u4ed6\u7684\u5b57\u5143\u3002<\/td><td><br>\u8acb\u8f2a\u51fa N \u5217\uff0c\u6bcf\u5217\u70ba\u9577\u5ea6\u6070\u70ba M \u7684\u5b57\u4e32\uff0c\u5c0d\u65bc\u7b2c i \u5217\u7684\u7b2c j \u500b\u5b57\u5143\uff0c\u82e5\u57ce\u5e02\u4e2d\u7b2c i \u5217\u7b2c j \u884c\u7684\u65b9\u683c\u53ef\u4ee5\u53bb\u64bf\u62fe\u7529\u68cd\uff0c\u5247\u8acb\u8f2a\u51fa\u300cX\u300d\uff08\u82f1\u6587\u5927\u5beb\u5b57\u6bcd\uff09\uff0c\u5426\u5247\u8acb\u8f38\u51fa\u300c#\u300d\u3002\u8acb\u52ff\u8f38\u51fa\u5176\u4ed6\u7684\u5b57\u5143\u6216\u7a7a\u767d\u3002<\/td><\/tr><tr><td>2  2<br>#.<br>..<\/td><td>##<br>#X<\/td><\/tr><tr><td>3  2<br>##<br>..<br>#.<\/td><td>##<br>##<br>##<\/td><\/tr><tr><td>1  4<br>..#.<\/td><td>####<\/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=\"\">\u4f7f\u7528\u4e8c\u7dad\u9663\u5217\u7684\u65b9\u5f0f\u6536\u5b57\u5143\uff0c\u6536\u8cc7\u6599\u7684\u6642\u5019\u53ef\u4ee5\u5224\u65b7\u76ee\u524d\u6536\u5230\u7684\u5b57\u5143\u662f\u5426\u70ba\u300c#\u300d\uff0c\u5982\u679c\u662f\u300c#\u300d\u7684\u8a71\u5c31\u7d00\u9304\u76ee\u524d\u7684 i \u548c j\u3002<\/p>\n\n\n\n<p class=\"\">\u53ef\u4ee5\u5ba3\u544a\u5169\u500b Map&lt;int, int>\uff0c\u4e00\u500b\u5b58 Row\uff0c\u53e6\u5916\u4e00\u500b\u5b58 Column\u3002\u8981\u5b58\u7684\u8a71\u5c31\u662f Row[i]++ \u8ddf Column[j]++\u3002<\/p>\n\n\n\n<p class=\"\">\u6536\u5b8c\u8cc7\u6599\u4e4b\u5f8c\u518d\u5c07\u6240\u6709\u7684\u5b57\u5143\u9032\u884c\u5224\u65b7\uff0c\u5982\u679c\u76ee\u524d\u5b57\u5143\u662f\u300c#\u300d\u7684\u8a71\uff0c\u5247\u8f38\u51fa\u300c#\u300d\u3002\u5982\u679c\u76ee\u524d\u5b57\u5143\u662f\u300c.\u300d\u7684\u8a71\u5c31\u5224\u65b7\u76ee\u524d\u7684 Row[i] \u8ddf Column[j] \u662f\u5426\u90fd\u662f 0\uff0c\u5982\u679c\u90fd\u662f 0 \u5c31\u53ef\u4ee5\u8f38\u51fa\u300cX\u300d\uff0c\u5426\u5247\u8f38\u51fa\u300c#\u300d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c833\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C833: \u4e8c\u7dad\u9663\u5217<\/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;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    vector&lt;vector&lt;char&gt;&gt;num;\n    map&lt;int, int&gt;row, column;\n    for (int i = 0; i&lt;N; i++)\n    {\n        vector&lt;char&gt;v;\n        for (int j = 0; j&lt;M; j++)\n        {\n            char ch;\n            cin &gt;&gt; ch;\n            if (ch == &#39;#&#39;)\n            {\n                row[i]++;\n                column[j]++;\n            }\n            v.push_back(ch);\n        }\n        num.push_back(v);\n    }\n    for (int i = 0; i&lt;N; i++)\n    {\n        for (int j = 0; j&lt;M; j++)\n        {\n            if (num[i][j] == &#39;#&#39;) cout &lt;&lt; &#39;#&#39;;\n            else\n            {\n                if (row[i] == 0 && column[j] == 0) cout &lt;&lt; &#39;X&#39;;\n                else cout &lt;&lt; &#39;#&#39;;\n            }\n        }\n        cout &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge C833\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e00\u5ea7\u53ef\u4ee5\u8996\u70ba\u4e8c\u7dad\u7684\u65b9\u683c\u5e73\u9762\u7684\u9577\u65b9\u5f62\u57ce\u5e02\uff0c\u7531\u4e0a\u800c\u4e0b\u5171\u6709 N \u5217\uff0c\u7531\u5de6\u81f3\u53f3\u5171\u6709 M \u884c\uff0c\u7e3d\u5171\u5283\u5206\u70ba N \u00d7 M  [&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":[29],"tags":[14,22,8,11,9],"class_list":["post-508","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-map","tag-22","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/508","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=508"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/508\/revisions"}],"predecessor-version":[{"id":509,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/508\/revisions\/509"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}