{"id":13,"date":"2025-03-24T21:39:29","date_gmt":"2025-03-24T13:39:29","guid":{"rendered":"http:\/\/120.76.99.214\/?p=13"},"modified":"2025-11-24T16:44:06","modified_gmt":"2025-11-24T08:44:06","slug":"%e5%ad%a6%e4%b9%a0%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/www.tgwttt.xyz\/?p=13","title":{"rendered":"\u5b66\u4e60\u8bb0\u5f55"},"content":{"rendered":"\n<p>\u7531\u4e8e\u84dd\u6865\u676f\u4e34\u8fd1\uff0c\u535a\u4e3b\u60f3\u5237\u70b9\u9898\u6765\u5145\u5b9e\u81ea\u5df1\uff0c\u8bdd\u4e0d\u591a\u5c11\uff0c\u770b\u9898\u3002<\/p>\n\n\n\n<p>\u5c0f\u84dd\u6700\u8fd1\u8ff7\u4e0a\u4e86\u4e00\u6b3e\u540d\u4e3a\u300a\u6570\u5b57\u63a5\u9f99\u300b\u7684\u8ff7\u5bab\u6e38\u620f\uff0c\u6e38\u620f\u5728\u4e00\u4e2a\u5927\u5c0f\u4e3aN \u00d7 N \u7684\u683c\u5b50\u68cb\u76d8\u4e0a\u5c55\u5f00\uff0c\u5176\u4e2d\u6bcf\u4e00\u4e2a\u683c\u5b50\u5904\u90fd\u6709\u7740\u4e00\u4e2a 0 . . . K \u2212 1 \u4e4b\u95f4\u7684\u6574\u6570\u3002\u6e38\u620f\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1. \u4ece\u5de6\u4e0a\u89d2 (0, 0) \u5904\u51fa\u53d1\uff0c\u76ee\u6807\u662f\u5230\u8fbe\u53f3\u4e0b\u89d2 (N \u2212 1, N \u2212 1) \u5904\u7684\u683c\u5b50\uff0c\u6bcf\u4e00\u6b65\u53ef\u4ee5\u9009\u62e9\u6cbf\u7740\u6c34\u5e73\/\u5782\u76f4\/\u5bf9\u89d2\u7ebf\u65b9\u5411\u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u683c\u5b50\u3002<\/p>\n\n\n\n<p>2. \u5bf9\u4e8e\u8def\u5f84\u7ecf\u8fc7\u7684\u68cb\u76d8\u683c\u5b50\uff0c\u6309\u7167\u7ecf\u8fc7\u7684\u683c\u5b50\u987a\u5e8f\uff0c\u4e0a\u9762\u7684\u6570\u5b57\u7ec4\u6210\u7684\u5e8f\u5217\u8981\u6ee1\u8db3\uff1a0, 1, 2, . . . , K \u2212 1, 0, 1, 2, . . . , K \u2212 1, 0, 1, 2 . . . \u3002<\/p>\n\n\n\n<p>3. \u9014\u4e2d\u9700\u8981\u5bf9\u68cb\u76d8\u4e0a\u7684\u6bcf\u4e2a\u683c\u5b50\u6070\u597d\u90fd\u7ecf\u8fc7\u4e00\u6b21\uff08\u4ec5\u4e00\u6b21\uff09\u3002<\/p>\n\n\n\n<p>4. \u8def\u5f84\u4e2d\u4e0d\u53ef\u4ee5\u51fa\u73b0\u4ea4\u53c9\u7684\u7ebf\u8def\u3002\u4f8b\u5982\u4e4b\u524d\u6709\u4ece (0, 0) \u79fb\u52a8\u5230 (1, 1)\uff0c\u90a3\u4e48\u518d\u4ece (1, 0) \u79fb\u52a8\u5230 (0, 1) \u7ebf\u8def\u5c31\u4f1a\u4ea4\u53c9\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u65b9\u4fbf\u8868\u793a\uff0c\u6211\u4eec\u5bf9\u53ef\u4ee5\u884c\u8fdb\u7684\u6240\u6709\u516b\u4e2a\u65b9\u5411\u8fdb\u884c\u4e86\u6570\u5b57\u7f16\u53f7\uff0c\u5982\u4e0b\u56fe2 \u6240\u793a\uff1b\u56e0\u6b64\u884c\u8fdb\u8def\u5f84\u53ef\u4ee5\u7528\u4e00\u4e2a\u5305\u542b 0 . . . 7 \u4e4b\u95f4\u7684\u6570\u5b57\u5b57\u7b26\u4e32\u8868\u793a\uff0c\u5982\u4e0b\u56fe 1\u662f\u4e00\u4e2a\u8ff7\u5bab\u793a\u4f8b\uff0c\u5b83\u6240\u5bf9\u5e94\u7684\u7b54\u6848\u5c31\u662f\uff1a41255214\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.dotcpp.com\/oj\/upload\/image\/20240413\/20240413200911_42459.png\" alt=\"\u84dd\u6865\u676f2024\u5e74\u7b2c\u5341\u4e94\u5c4a\u7701\u8d5b\u771f\u9898-\u6570\u5b57\u63a5\u9f99\" title=\"\u84dd\u6865\u676f2024\u5e74\u7b2c\u5341\u4e94\u5c4a\u7701\u8d5b\u771f\u9898-\u6570\u5b57\u63a5\u9f99\"\/><\/figure>\n\n\n\n<p>\u73b0\u5728\u8bf7\u4f60\u5e2e\u5c0f\u84dd\u89c4\u5212\u51fa\u4e00\u6761\u884c\u8fdb\u8def\u5f84\u5e76\u5c06\u5176\u8f93\u51fa\u3002\u5982\u679c\u6709\u591a\u6761\u8def\u5f84\uff0c\u8f93\u51fa\u5b57\u5178\u5e8f\u6700\u5c0f\u7684\u90a3\u4e00\u4e2a\uff1b\u5982\u679c\u4e0d\u5b58\u5728\u4efb\u4f55\u4e00\u6761\u8def\u5f84\uff0c\u5219\u8f93\u51fa \u22121\u3002<\/p>\n\n\n\n<p>\u663e\u7136\u9898\u76ee\u662f\u7528DFS+\u526a\u679d\uff0c\u91cd\u70b9\u5728\u4e8e\u5904\u7406\u4ea4\u53c9\u7684\u60c5\u51b5\uff0c\u7531\u4e8e\u6570\u636e\u91cf\u633a\u5c0f\uff0c\u535a\u4e3b\u5c31\u5f00\u4e86\u4e00\u4e2a\u56db\u4f4d\u6570\u7ec4\u5b58\u50a8\u3002<\/p>\n\n\n\n<p>c++\u4ee3\u7801<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<pre class=\"wp-block-code\"><code>#include<iostream>\n#include<string>\n#include<vector>\nusing namespace std;\nvector<int>s;\/\/\u83b7\u53d6\u5230\u7684\u6570\u7ec4\u60c5\u51b5\nvector<vector<int>>num1;\/\/\u83b7\u53d6\u540e\u6309\u5b57\u5178\u987a\u5e8f\u5b58\u653e\nint dx[] = { 0,1,1,1,0,-1,-1,-1 };\/\/x\u65b9\u5411\nint dy[] = { 1,1,0,-1,-1,-1,0,1 };\/\/y\u65b9\u5411\nint n, k;\nint num = 0;\nint arr[11][11] = { -1 };\/\/\u8bb0\u5f55\u6570\u7ec4\nint arr1[11][11] = { -1 };\/\/\u8bb0\u5f55\u8bbf\u95ee\u60c5\u51b5\nint arr2[11][11][11][11] = { -1 };\/\/\u8bb0\u5f55\u4ea4\u53c9\u60c5\u51b5\nvoid dfs(int x, int y) {\n    arr1[x][y] = 0;\n    if (x == n && y == n) {\n        if (s.size() == n)\n            for (int i = 0; i < s.size();i++) {\n                cout << s[i];\n            }\n            num1.push_back(s);\n    }\n    else {\n        if (num == k - 1)num = -1;\n        else {\n            for (int i = 0; i < 8; i++) {\/\/\u904d\u53868\u4e2a\u65b9\u5411\n                if (arr1[x + dx[i]][y + dx[i]] == 0)continue;\n                if (arr[x + dx[i]][y + dx[i]] != num + 1)continue;\n                if (i == 1 &#038;&#038; arr2[x][y - 1][x + dx[i] + 1][y + dy[i]] == 1)continue;\n                if (i == 3 &#038;&#038; arr2[x + 1][y][x + dx[i] - 1][y + dy[i]] == 1)continue;\n                if (i == 5 &#038;&#038; arr2[x][y - 1][x + dx[i]][y + dy[i] + 1] == 1)continue;\n                if (i == 7 &#038;&#038; arr2[x - 1][y][x + dx[i]][y + dy[i] - 1] == 1)continue;\n                s.push_back(i);\n                arr2[x + dx[i]][y + dy[i]][x][y] = 1;\n                arr2[x][y][x + dx[i]][y + dy[i]] = 1;\n                num++;\n                dfs(x + dx[i], y + dx[i]);\n                num--;\n                arr2[x][y][x + dx[i]][y + dy[i]] = -1;\n                arr2[x + dx[i]][y + dy[i]][x][y] = -1;\n                arr1[x][y] = -1;\n                s.pop_back();\n            }\n        }\n    }\n}\nint main()\n{\n    cin >> n >> k;\n    for (int i= 1; i <= n; i++) {\n        for (int j = 1; j <= n; j++) {\n            cin >> arr[i][j];\n        }\n    }\n    return 0;\n}\n<\/code><\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8e\u84dd\u6865\u676f\u4e34\u8fd1\uff0c\u535a\u4e3b\u60f3\u5237\u70b9\u9898\u6765\u5145\u5b9e\u81ea\u5df1\uff0c\u8bdd\u4e0d\u591a\u5c11\uff0c\u770b\u9898\u3002 \u5c0f\u84dd\u6700\u8fd1\u8ff7\u4e0a\u4e86\u4e00\u6b3e\u540d\u4e3a\u300a\u6570\u5b57\u63a5\u9f99\u300b\u7684\u8ff7\u5bab\u6e38\u620f\uff0c\u6e38\u620f\u5728&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":4,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":899,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/899"}],"wp:attachment":[{"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tgwttt.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}