{"id":208,"date":"2026-05-21T09:15:40","date_gmt":"2026-05-21T01:15:40","guid":{"rendered":"https:\/\/huxiaole.cloud\/?p=208"},"modified":"2026-05-21T09:15:42","modified_gmt":"2026-05-21T01:15:42","slug":"hdu-1429%ef%bc%9a%e8%83%9c%e5%88%a9%e5%a4%a7%e9%80%83%e4%ba%a1%e7%bb%ad","status":"publish","type":"post","link":"https:\/\/huxiaole.cloud\/index.php\/2026\/05\/21\/hdu-1429%ef%bc%9a%e8%83%9c%e5%88%a9%e5%a4%a7%e9%80%83%e4%ba%a1%e7%bb%ad\/","title":{"rendered":"HDU 1429\uff1a\u80dc\u5229\u5927\u9003\u4ea1(\u7eed)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6700\u8fd1\u60f3\u5199\u8ff7\u5bab\u4e86\uff0c\u8ff7\u5bab\u597d\u73a9<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">HDU 1429\uff1a\u80dc\u5229\u5927\u9003\u4ea1(\u7eed)<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Time Limit:<\/strong> 4000\/2000 MS (Java\/Others)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Memory Limit:<\/strong> 65536\/32768 K (Java\/Others)<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ignatius \u518d\u6b21\u88ab\u9b54\u738b\u6293\u8d70\u4e86\u3002\u8fd9\u6b21\u9b54\u738b\u6c72\u53d6\u4e86\u4e0a\u6b21\u7684\u6559\u8bad\uff0c\u628a Ignatius \u5173\u5728\u4e00\u4e2a <code>n * m<\/code> \u7684\u5730\u7262\u91cc\uff0c\u5e76\u5728\u5730\u7262\u7684\u67d0\u4e9b\u5730\u65b9\u5b89\u88c5\u4e86\u5e26\u9501\u7684\u95e8\uff0c\u800c\u5f00\u95e8\u7684\u94a5\u5319\u85cf\u5728\u5730\u7262\u7684\u5176\u4ed6\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521a\u5f00\u59cb\uff0cIgnatius \u88ab\u5173\u5728 <code>(sx, sy)<\/code> \u7684\u4f4d\u7f6e\u3002<br><\/li>\n\n\n\n<li>\u79bb\u5f00\u5730\u7262\u7684\u51fa\u53e3\u5728 <code>(ex, ey)<\/code> \u7684\u4f4d\u7f6e\u3002<br><\/li>\n\n\n\n<li>Ignatius \u6bcf\u5206\u949f\u53ea\u80fd\u4ece\u5f53\u524d\u5750\u6807\u79fb\u52a8\u5230\u76f8\u90bb\u7684\u56db\u4e2a\u5750\u6807\u4e4b\u4e00\u3002<br><\/li>\n\n\n\n<li>\u9b54\u738b\u6bcf <code>t<\/code> \u5206\u949f\u4f1a\u56de\u5730\u7262\u89c6\u5bdf\u4e00\u6b21\uff0c\u82e5\u53d1\u73b0 Ignatius \u4e0d\u5728\u539f\u4f4d\u7f6e\uff0c\u4fbf\u4f1a\u628a\u4ed6\u62ce\u56de\u53bb\u3002<br><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ecf\u8fc7\u82e5\u5e72\u6b21\u5c1d\u8bd5\uff0cIgnatius \u5df2\u7ecf\u753b\u51fa\u4e86\u6574\u4e2a\u5730\u7262\u7684\u5730\u56fe\u3002\u73b0\u5728\u8bf7\u4f60\u5e2e\u4ed6\u8ba1\u7b97\u80fd\u5426\u518d\u6b21\u6210\u529f\u9003\u4ea1\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u9003\u4ea1\u6210\u529f\u5224\u5b9a\uff1a<\/strong> \u53ea\u8981\u5728\u9b54\u738b\u4e0b\u6b21\u89c6\u5bdf<strong>\u4e4b\u524d<\/strong>\u8d70\u5230\u51fa\u53e3\u5c31\u7b97\u79bb\u5f00\u5730\u7262\u3002\u5982\u679c\u9b54\u738b\u56de\u6765\u7684\u65f6\u5019\u521a\u597d\u8d70\u5230\u51fa\u53e3\uff0c\u6216\u8005\u8fd8\u672a\u5230\u51fa\u53e3\uff0c\u5747\u7b97\u4f5c\u9003\u4ea1\u5931\u8d25\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5730\u56fe\u5143\u7d20\u8bf4\u660e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5730\u56fe\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>.<\/code> \uff1a\u4ee3\u8868\u901a\u8def<br><\/li>\n\n\n\n<li><code>*<\/code> \uff1a\u4ee3\u8868\u5899\u58c1\uff08\u4e0d\u53ef\u901a\u884c\uff09<br><\/li>\n\n\n\n<li><code>@<\/code> \uff1a\u4ee3\u8868 Ignatius \u7684\u8d77\u59cb\u4f4d\u7f6e<br><\/li>\n\n\n\n<li><code>^<\/code> \uff1a\u4ee3\u8868\u5730\u7262\u7684\u51fa\u53e3<br><\/li>\n\n\n\n<li><code>A-J<\/code> \uff1a\u4ee3\u8868\u5e26\u9501\u7684\u95e8\uff08\u5bf9\u5e94\u7684\u94a5\u5319\u5206\u522b\u4e3a <code>a-j<\/code>\uff09<br><\/li>\n\n\n\n<li><code>a-j<\/code> \uff1a\u4ee3\u8868\u94a5\u5319\uff08\u5bf9\u5e94\u7684\u95e8\u5206\u522b\u4e3a <code>A-J<\/code>\uff09<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5305\u542b\u591a\u7ec4\u6d4b\u8bd5\u6570\u636e\u3002\u6bcf\u7ec4\u6d4b\u8bd5\u6570\u636e\u4e4b\u95f4\u6709\u4e00\u4e2a\u7a7a\u884c\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6bcf\u7ec4\u6570\u636e\u7684\u7b2c\u4e00\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570 <code>n<\/code>, <code>m<\/code>, <code>t<\/code> (<code>2 &lt;= n, m &lt;= 20<\/code>, <code>t > 0<\/code>)\uff0c\u5206\u522b\u4ee3\u8868\u5730\u7262\u7684\u884c\u6570\u3001\u5217\u6570\u4ee5\u53ca\u9b54\u738b\u89c6\u5bdf\u7684\u65f6\u95f4\u95f4\u9694\u3002<\/li>\n\n\n\n<li>\u63a5\u4e0b\u6765\u7684 <code>n<\/code> \u884c\uff0c\u6bcf\u884c\u5305\u542b <code>m<\/code> \u4e2a\u5b57\u7b26\uff0c\u8868\u793a\u5730\u7262\u7684\u5730\u56fe\u5206\u5e03\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9488\u5bf9\u6bcf\u7ec4\u6d4b\u8bd5\u6570\u636e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u53ef\u4ee5\u6210\u529f\u9003\u4ea1\uff0c\u8bf7\u8f93\u51fa<strong>\u6700\u5c11\u9700\u8981\u591a\u5c11\u5206\u949f<\/strong>\u624d\u80fd\u79bb\u5f00\u3002<br><\/li>\n\n\n\n<li>\u5982\u679c\u4e0d\u80fd\u9003\u4ea1\uff08\u65e0\u6cd5\u5230\u8fbe\u51fa\u53e3\u6216\u8d85\u65f6\uff09\uff0c\u5219\u8f93\u51fa <code>-1<\/code>\u3002<br><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u6837\u4f8b\u8f93\u5165<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>4 5 17\n@A.B.\na*.*.\n*..*^\nc..b*\n\n4 5 16\n@A.B.\na*.*.\n*..*^\nc..b*\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6837\u4f8b\u8f93\u51fa<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>16\n-1\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u72b6\u6001\u538b\u7f29\uff0c\u56e0\u4e3a\u4e00\u517110\u628a\u94a5\u5319\uff0c\u6211\u4eec\u53ea\u80fd\u7528\u72b6\u6001\u538b\u7f29\uff0c\u4e00\u4e8c\u7ef4\u8bb0\u5f55\u5750\u6807\uff0c\u4e09\u7ef4\u5b58\u6709\u4ec0\u4e48\u94a5\u5319<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7406\u89e3\uff0c\u72b6\u6001\u538b\u7f29\u662f\u4e3a\u4e86\u540c\u65f6\u8bb0\u5f55\u591a\u4e2a\u72b6\u6001\u800c\u4ea7\u751f\u7684\uff0c\u72b6\u6001\u662f\u6709\uff081\uff09\uff0c\u65e0\uff080\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Sunshine, sunshine, ladybugs awake!\n\n\/\/ Clap your hooves and do a little shake!\n\n#include &lt;bits\/stdc++.h&gt;\n\n#define int long long\n\n#define endl '\\n'\n\nusing namespace std;\n\n  \n\nusing PII=pair&lt;int,int&gt; ;\n\n  \n\nconst int mod=666623333;\n\nconst int MAXN=25;\n\n  \n\nint dx&#91;4]={0,0,1,-1};\n\nint dy&#91;4]={1,-1,0,0};\n\nbool vis&#91;MAXN]&#91;MAXN]&#91;2&lt;&lt;10];\n\nchar g&#91;MAXN]&#91;MAXN];\n\n  \n\nint n,m,k;\n\nstruct Node{\n\n&nbsp; &nbsp; int x,y,key,tim;\n\n};\n\n  \n\nvoid solve() { &nbsp;\n\n&nbsp; &nbsp; memset(vis,false,sizeof(vis));\n\n&nbsp; &nbsp; int st_x,st_y,ed_x,ed_y;\n\n&nbsp; &nbsp; for(int i=1;i&lt;=n;i++){\n\n&nbsp; &nbsp; &nbsp; &nbsp; for(int j=1;j&lt;=m;j++){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;g&#91;i]&#91;j];\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(g&#91;i]&#91;j]=='@'){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; st_x=i;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; st_y=j;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(g&#91;i]&#91;j]=='^'){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed_x=i;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed_y=j;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; queue&lt;Node&gt; q;\n\n&nbsp; &nbsp; q.push({st_x,st_y,0ll,0ll});\n\n&nbsp; &nbsp; vis&#91;st_x]&#91;st_y]&#91;0]=true;\n\n&nbsp; &nbsp; while(!q.empty()){\n\n&nbsp; &nbsp; &nbsp; &nbsp; auto &#91;x,y,key,t]=q.front();\n\n&nbsp; &nbsp; &nbsp; &nbsp; q.pop();\n\n&nbsp; &nbsp; &nbsp; &nbsp; if(t&gt;=k){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;-1&lt;&lt;endl;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &nbsp;;\n\n&nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; if(x==ed_x&amp;&amp;y==ed_y){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;t&lt;&lt;endl;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return ;\n\n&nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0;i&lt;4;i++){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int nx=x+dx&#91;i];\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int ny=y+dy&#91;i];\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(g&#91;nx]&#91;ny]=='*')continue;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(nx&lt;1||nx&gt;n||ny&lt;1||ny&gt;m)continue;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int nkey=key;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(g&#91;nx]&#91;ny]&gt;='A'&amp;&amp;g&#91;nx]&#91;ny]&lt;='J'){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!(nkey&amp;(1ll&lt;&lt;(g&#91;nx]&#91;ny]-'A')))){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(g&#91;nx]&#91;ny]&gt;='a'&amp;&amp;g&#91;nx]&#91;ny]&lt;='j'){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nkey|=(1ll&lt;&lt;(g&#91;nx]&#91;ny]-'a'));\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!vis&#91;nx]&#91;ny]&#91;nkey]){\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vis&#91;nx]&#91;ny]&#91;nkey] = true;\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q.push({nx, ny, nkey, t + 1});\n\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; &nbsp; &nbsp; }\n\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; cout &lt;&lt; -1 &lt;&lt; endl;\n\n}\n\n  \n\nsigned main() {\n\n&nbsp; &nbsp; ios_base::sync_with_stdio(false);\n\n&nbsp; &nbsp; cin.tie(NULL);\n\n&nbsp; &nbsp; \/\/int t;cin &gt;&gt; t;while (t--)\n\n&nbsp; &nbsp; while(cin&gt;&gt;n&gt;&gt;m&gt;&gt;k) solve();\n\n&nbsp; &nbsp; return 0;\n\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u60f3\u5199\u8ff7\u5bab\u4e86\uff0c\u8ff7\u5bab\u597d\u73a9 HDU 1429\uff1a\u80dc\u5229\u5927\u9003\u4ea1(\u7eed) Time Limit: 4000\/2000 MS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":212,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,23,9],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hdu","category-23","category-9"],"_links":{"self":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":1,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/208\/revisions\/215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media\/212"}],"wp:attachment":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}