{"id":290,"date":"2024-04-27T12:26:23","date_gmt":"2024-04-27T04:26:23","guid":{"rendered":"https:\/\/seanxd.com\/?p=290"},"modified":"2024-04-27T12:26:25","modified_gmt":"2024-04-27T04:26:25","slug":"zerojudge-k732","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-k732\/","title":{"rendered":"ZeroJudge K732: Special Position"},"content":{"rendered":"\n\n\n<p class=\"\">\u7d66\u5b9a\u4e00\u500b N\uff0aM \u7684\u4e8c\u7dad\u77e9\u9663 A\uff0c\u8a2d x = A[i][j]\uff0c<strong>\u96e2 (i, j) \u66fc\u54c8\u9813\u8ddd\u96e2\u70ba x \u5167\u7684\u9ede\u6578\u503c\u7e3d\u548c % 10 (\u9664\u4ee5 10 \u5f8c\u7684\u9918\u6578) \u6070\u70ba x \u7684\u7a31\u4e4b\u70ba\u7279\u6b8a\u4f4d\u7f6e<\/strong>\u3002\u5b9a\u7fa9\u5169\u500b\u9ede (a, b) \u548c (c, d) \u7684\u66fc\u54c8\u9813\u8ddd\u96e2\u70ba |a &#8211; c| + |b &#8211; d|\u3002<\/p>\n\n\n\n<p class=\"\">\u8acb\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c<strong>\u8f38\u51fa\u5171\u6709\u5e7e\u500b\u7279\u6b8a\u4f4d\u7f6e<\/strong>\uff0c\u4e26<strong>\u6309\u7167\u5b57\u5178\u5e8f\u7531\u5c0f\u5230\u5927\u8f38\u51fa<\/strong>\u9019\u4e9b\u4f4d\u7f6e\u7684\u5ea7\u6a19\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\u8f38\u5165\u5169\u500b\u6b63\u6574\u6578 N \u548c M (1 &lt;= N, M &lt;= 50)\uff0c\u63a5\u4e0b\u4f86\u6709 N \u884c\uff0c\u6bcf\u884c\u6709 M \u500b\u6578\u5b57\uff0c\u6bcf\u4e00\u500b\u6578\u5b57\u4ecb\u65bc 0 \u5230 9 \u3002<\/td><td>\u7b2c\u4e00\u884c\u8f38\u51fa\u5171\u6709\u5e7e\u500b\u7279\u6b8a\u4f4d\u7f6e\uff0c\u63a5\u4e0b\u4f86\u8f38\u51fa K \u884c\uff0c\u6bcf\u4e00\u884c\u8f38\u51fa\u5169\u500b\u6b63\u6574\u6578\u4ee3\u8868\u4f5c\u6a19\u9ede\u4f4d\u3002\u7279\u6b8a\u4f4d\u7f6e\u8acb<strong>\u6309\u7167\u5b57\u5178\u9806\u5e8f\u7531\u5c0f\u5230\u5927\u8f38\u51fa<\/strong>\u3002<\/td><\/tr><tr><td>1  8<br>1  2  3  4  5  6  7  8<\/td><td>1<br>0  5<\/td><\/tr><tr><td>2  3<br>5  2  3<br>4  5  6<\/td><td>2<br>0  0<br>1  1<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge K732 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u5224\u65b7\u6bcf\u500b\u9ede\u7684\u66fc\u54c8\u9813\u8ddd\u96e2\u908a\u754c (\u4e0a\u4e0b\u5de6\u53f3)\uff0c\u4f46\u662f<strong>\u4e0d\u80fd\u8d85\u904e\u9663\u5217\u7684\u908a\u754c<\/strong>\u3002<strong>\u5f9e\u9ede\u5ef6\u4f38\u5230\u66fc\u54c8\u9813\u8ddd\u96e2\u908a\u754c\u61c9\u8a72\u6703\u662f\u4e00\u500b\u300c\u83f1\u5f62\u7684\u6a23\u5b50\u300d<\/strong>\uff0c\u4f7f\u7528 <strong>For\u8ff4\u5708<\/strong> \u5c07<strong>\u83f1\u5f62\u4e2d\u7684\u6578\u503c\u52a0\u5728\u4e00\u8d77\u5f8c\u5c0d 10 \u53d6\u9918\u6578<\/strong>\u5373\u53ef\u3002\u5ea7\u6a19\u7684\u7b54\u6848\u53ef\u4ee5\u5b58\u653e\u5728<strong> \u9663\u5217\/Vector <\/strong>\u4e2d\uff0c\u9019\u6a23\u53ef\u4ee5\u76f4\u63a5\u7528 <strong>Sort<\/strong> \u6392\u5e8f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=k732\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge K732: \u7279\u6b8a\u4f4d\u7f6e<\/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;algorithm&gt;\nusing namespace std;\n\npair&lt;int, int&gt; axis (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    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;int&gt;&gt;num;\n    for (int i = 0; i&lt;N; i++)\n    {\n        vector&lt;int&gt;hi;\n        for (int j = 0; j&lt;M; j++)\n        {\n            int tmp;\n            cin &gt;&gt; tmp;\n            hi.push_back(tmp);\n        }\n        num.push_back(hi);\n    }\n    vector&lt;pair&lt;int, int&gt;&gt;ans;\n    for (int i = 0; i&lt;N; i++)\n    {\n        for (int j = 0; j&lt;M; j++)\n        {\n            int x = num[i][j];\n            int left = 0, right = M-1;\n            if (j - x &gt;= 0) left = j - x;\n            if (j + x &lt;= M-1) right = j + x;\n            int enumeration = 0;\n            for (int k = left; k&lt;=right; k++)\n            {\n                int up = i-(x - abs(j-k));\n                int down = i+(x - abs(j-k));\n                if (up &lt;= 0) up = 0;\n                if (down &gt;= N-1) down = N-1;\n                for (int l = down; l&gt;=up; l--)\n                {\n                    enumeration += num[l][k];\n                }\n            }\n            if (enumeration % 10 == x)\n            {\n                ans.push_back(axis(i, j));\n            }\n        }\n    }\n    sort(ans.begin(), ans.end());\n    cout &lt;&lt; ans.size() &lt;&lt; &quot;\\n&quot;;\n    for (int i = 0; i&lt;ans.size(); i++)\n    {\n        cout &lt;&lt; ans[i].first &lt;&lt; &quot; &quot; &lt;&lt; ans[i].second &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge K732\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7d66\u5b9a\u4e00\u500b N\uff0aM \u7684\u4e8c\u7dad\u77e9\u9663 A\uff0c\u8a2d x = A[i][j]\uff0c\u96e2 (i, j) \u66fc\u54c8\u9813\u8ddd\u96e2\u70ba x \u5167\u7684\u9ede\u6578\u503c\u7e3d [&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":[23,20,22,8,19,13,9],"class_list":["post-290","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-pair","tag-20","tag-22","tag-8","tag-19","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/290","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=290"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/290\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/290\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}