{"id":252,"date":"2011-11-30T02:11:20","date_gmt":"2011-11-29T18:11:20","guid":{"rendered":"http:\/\/ykyi.net\/?p=252"},"modified":"2011-11-30T02:11:20","modified_gmt":"2011-11-29T18:11:20","slug":"%e7%86%ac%e5%a4%9c%e5%ae%8c%e6%88%90-sicily1153-%e9%a9%ac%e5%91%a8%e6%b8%b8%e8%a7%a3%e9%a2%98%e6%8a%a5%e5%91%8a%e3%80%82%e5%9b%b0%e6%ad%bb%e5%93%a5%e4%ba%86","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=252","title":{"rendered":"\u71ac\u591c\u5b8c\u6210 sicily1153 \u9a6c\u5468\u6e38\u89e3\u9898\u62a5\u544a\u3002\u56f0\u6b7b\u54e5\u4e86."},"content":{"rendered":"<div>\n<p><span style=\"line-height: 1.6em;\">\u5509\uff01\uff01\uff01 \u4e0a\u6b21\u4ea4\u4f5c\u4e1a\u5199\u9519\u9898\u76ee\u4e86\uff0c\u505a\u4e86\u7b80\u5355\u7684\u9a6c\u5468\u6e38 sicily 1152\u3002\u8865\u4e0a\u65b0\u7684,\u5e94\u8be5\u662fsicily 1153.\u4e3a\u4e86\u89e3\u51b3\u89c4\u6a21\u592a\u5927\u7684\u95ee\u9898\u3002\u52a0\u4e0a\u4e86\u4f18\u5316\u7b97\u6cd5\u3002<\/span><\/p>\n<div>&nbsp;<\/div>\n<div>\u4e2d\u5927ACM\u5b9e\u9a8c\u9898\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>\uff081\uff09\u539f\u9898\u4e2d\u6587\u5927\u610f<\/div>\n<div>&nbsp;<\/div>\n<div>\u4e2d\u56fd\u8c61\u68cb\u7684\u9a6c\u6309\u7167\u8c61\u68cb\u7684\u89c4\u5219\u57288 x 8 \u7684\u68cb\u76d8\u4e0a\u8dd164\u6b65\u8dd1\u5b8c\u6240\u6709\u7684\u683c\u5b50\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>\uff082\uff09\u7b97\u6cd5\u601d\u60f3\u53ca\u89e3\u9898\u7528\u5230\u7684\u4e3b\u8981\u6570\u636e\u7ed3\u6784<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>\u4ece\u6bcf\u4e00\u4e2a\u70b9\u5f80\u4e0b\u8d70\u7b2c\u4e8c\u6b65\uff0c\u4f1a\u6709\u51e0\u70b9\u6709\u6548\u7684\u884c\u8d70\u4f4d\u7f6e\u3002 \u628a\u5f53\u524d\u4f4d\u7f6e\u8bb0\u5728\u6808\u91cc\u9762\uff0c\u4ee5\u6df1\u5ea6\u4f18\u5148\u7684\u65b9\u5f0f\u8fdb\u5165\u4e0b\u4e00\u4e2a\u6709\u6548\u4f4d\u7f6e\u3002\u5982\u679c\u4e0b\u4e00\u4e2a\u6709\u6548\u4f4d\u7f6e\u5728\u4e4b\u524d\u5df2\u7ecf\u8d70\u8fc7\uff0c\u5219\u4ece\u6808\u9876\u5f39\u51fa\u4e0a\u4e00\u4f4d\u7f6e\uff0c\u6062\u590d\u5230\u8c03\u51fa\u7684\u4f4d\u7f6e\u540e\u5c1d\u8bd5\u672a\u8d70\u8fc7\u7684\u6709\u6548\u4f4d\u7f6e\u3002\u5229\u7528\u51fd\u6570\u8c03\u7528\u65f6\u4f1a\u538b\u6808\u7684\u7279\u522b\uff0c\u7528\u51fd\u6570\u9012\u5f52\u8c03\u7528\u5373\u53ef\u89e3\u51b3\u95ee\u9898\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>\u8f6f\u4e4b\u7b80\u5355\u7684\u9a6c\u5468\u6e38\uff0c8 x 8 \u68cb\u76d8\u7684\u89c4\u6a21\u975e\u5e38\u5927\u3002\u9700\u8981\u5728\u53ef\u9009\u4e0b\u4e00\u6b65\u4e2d\u627e\u5230\u6700\u63a5\u8fd1\u6b63\u786e\u8def\u7ebf\u7684\u70b9\u3002\u6c42\u8be5\u70b9\u7684\u529e\u6cd5\u662f\u628a\u6240\u4ee5\u7684\u53ef\u9009\u70b9\u5148\u627e\u51fa\uff0c\u518d\u7ed9\u8fd9\u4e9b\u53ef\u9009\u70b9\u6309\u6743\u91cd\u6392\u5e8f\uff0c\u4ece\u6700\u4f18\u7684\u89e3\u4f9d\u6b21\u5411\u6b21\u4f18\uff0c\u6b21\u6b21\u4f18&#8230;..\u7684\u70b9\u8bd5\u63a2\u3002\u91cd\u70b9\u5728\u6743\u91cd\u7684\u7b97\u6cd5\u3002\u8fd9\u91cc\u7684\u6743\u91cd\u7684\u8ba1\u7b97\u6cd5\u5219\u662f\u6307\u4e00\u4e2a\u70b9\u7684\u4e0b\u4e00\u6b21\u53ef\u8d70\u7684\u70b9\u7684\u4e2a\u6570\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>\u4e3b\u8981\u7684\u6570\u636e\u7ed3\u6784\u6709\uff1a<\/div>\n<div>&nbsp;<\/div>\n<div>\n<pre class=\"brush:cpp\">\/\/ elocution\u6570\u7ec4\u5728\u521d\u59cb\u5316\u540e\u4f1a\u8bb0\u4e0b\u6bcf\u4e2a\u6709\u6548\u4f4d\u7f6e\u7684\u4e0b\u4e00\u6b65\u6709\u54ea\u4e9b\u53ef\u8d70\u4f4d\n\n\/\/ \u7f6e.elocution[x][0]\u7528\u4e0b\u68070\u8bb0\u4e2a\u6570\u3002\u6700\u591a8\u4e2a\u6709\u6548\u53ef\u8d70\u4f4d\u7f6e\u3002\n\nchar elocution[ELEM_COUNT][9];\n\n\/\/ stamps\u6570\u7ec4\u8bb0\u6bcf\u4e2a\u70b9\u662f\u5426\u5df2\u7ecf\u8d70\u8fc7\u4e86\u30020\u8868\u793a\u6ca1\u8d70\u8fc7\uff0c1\u8868\u793a\u8d70\u8fc7\u4e86\u3002\n\nchar stamps[ELEM_COUNT];\n\n\/\/ track\u6570\u7ec4\u8bb0\u8def\u5f84\u7684\u987a\u5e8f\u3002\n\nchar track[ELEM_COUNT];\n\n\u901a\u8fc7\u7ed3\u5408stamps\u6570\u7ec4\u548celocution\u6570\u7ec4\u53ef\u4ee5\u7b97\u51fa\u4e0b\u4e00\u6b65\u7684\u6bcf\u4e2a\u70b9\u7684\u6743\u91cd\u3002\n\n\n\n\uff083\uff09\u8be6\u7ec6\u89e3\u9898\u601d\u8def\n\n1. \u5148\u521d\u59cb\u5316\u4e00\u5f20\u8868\u3002\u8fd9\u5f20\u8868\u8bb0\u4e0b\u4e86\u68cb\u76d8\u4e0a\u6240\u6709\u768430\u4e2a\u4f4d\u7f6e\u7684\u4e0b\u4e00\u6b65\u53ef\u8d70\u7684\u6709\u6548\u4f4d\u7f6e.\n\n2. \u5199\u4e00\u4e2a\u4e00\u822c\u7684\u9012\u5f52\u8c03\u7528\u81ea\u5df1\u7684\u51fd\u6570\uff0c\u8868\u793a\u9a6c\u5728\u8d70\u7b2c\u51e0\u6b65\u65f6\u5230\u4e86\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u7136\u540e\u6c42\u51fa\u4f59\u4e0b\u7684\u6240\u6709\u53ef\u8d70\u4f4d\u7f6e\u3002\n\n3. \u4f59\u4e0b\u7684\u6240\u6709\u4f4d\u7f6e\u6309\u7167\u4e0a\u6587\u63d0\u5230\u7684\u6743\u91cd\u6392\u5e8f\u3002\n\n4. \u5bf9\u4e8e\u6392\u5e8f\u540e\u7684\u53ef\u9009\u70b9\u6570\u7ec4\uff0c\u6309\u987a\u5e8f\u4f9d\u6b21\u7528\u9012\u5f52\u51fd\u6570\u5c1d\u8bd5\u3002\n\n5. \u9012\u5f52\u51fd\u6570\u6709\u4e09\u4e2a\u9000\u51fa\u6761\u4ef6\u30021.\u4e0b\u4e00\u4e2a\u8981\u5c1d\u8bd5\u7684\u70b9\u5df2\u7ecf\u8d70\u8fc7\u4e86\uff0c2.\u8bd5\u5b8c\u4e86\u6240\u6709\u7684\u53ef\u9009\u4e0b\u4e00\u6b65\u65e0\u89e3\u30023.\u8d70\u5230\u4e86\u6700\u540e\u4e00\u6b65\uff0c\u5373\u5f97\u89e3\uff01\n\n\n\n\uff084\uff09\u7b97\u6cd5\u63cf\u8ff0\n\n\u521d\u5982\u5316\u4e0a\u6587\u63d0\u5230\u7684elocution\u6570\u7ec4\uff0c\u6e05\u7a7astamps\u548ctracks.\u4ece\u8d77\u70b9\u5f00\u59cb\u8c03\u7528\u9012\u5f52\u51fd\u6570\u3002\n\nhttp:\/\/ykyi.net  zausiu&#39;s blog.\n\n\n\n\uff085\uff09\u7a0b\u5e8f\u6ce8\u91ca\u6e05\u5355\n\n#include &lt;iostream&gt;\n\n#include &lt;cstring&gt;\n\n#include &lt;cstdlib&gt;\n\n#include &lt;vector&gt;\n\n#include &lt;csetjmp&gt;\n\n\/\/#include &lt;cassert&gt;\n\n\n\nusing namespace std;\n\n\n\n#define  ROW_NUM     8\n\n#define  COLUMN_NUM  8\n\n#define  ELEM_COUNT ROW_NUM * COLUMN_NUM\n\n\n\njmp_buf jmpbuffer;  \/\/ \u5f88\u6df1\u7684\u51fd\u6570\u9012\u5f52\u8c03\u7528\u65f6\u7528longjmp\u5feb\u901f\u9000\u51fa.\n\n\n\n\/\/ elocution\u6570\u7ec4\u5728\u521d\u59cb\u5316\u540e\u4f1a\u8bb0\u4e0b\u6bcf\u4e2a\u6709\u6548\u4f4d\u7f6e\u7684\u4e0b\u4e00\u6b65\u6709\u54ea\u4e9b\u53ef\u8d70\u4f4d\n\n\/\/ \u7f6e.elocution[x][0]\u7528\u4e0b\u68070\u8bb0\u4e2a\u6570\u3002\u6700\u591a8\u4e2a\u6709\u6548\u53ef\u8d70\u4f4d\u7f6e\u3002\n\nchar elocution[ELEM_COUNT][9];\n\n\n\n\/\/ stamps\u6570\u7ec4\u8bb0\u6bcf\u4e2a\u70b9\u662f\u5426\u5df2\u7ecf\u8d70\u8fc7\u4e86\u30020\u8868\u793a\u6ca1\u8d70\u8fc7\uff0c1\u8868\u793a\u8d70\u8fc7\u4e86\u3002\n\nchar stamps[ELEM_COUNT];\n\n\n\nstruct coordinate  \/\/ \u4e8c\u7ef4\u5750\u6807\n\n{\n\nchar _x;  \/\/ start from zero.\n\nchar _y;\n\n};\n\n\n\n\/\/ \u4f5c\u6807\u8f6c\u5e8f\u53f7\n\nchar coordinate2serial_num(coordinate co)\n\n{\n\nchar num = co._x * COLUMN_NUM + co._y + 1;\n\nreturn num;\n\n}\n\n\/\/ \u5e8f\u53f7\u8f6c\u5750\u6807\n\ncoordinate serial_num2coordinate(char sn)\n\n{\n\ncoordinate co;\n\nco._x = (sn - 1) \/ COLUMN_NUM;\n\nco._y = sn - co._x * COLUMN_NUM - 1;\n\nreturn co;\n\n}\n\n\n\n\/\/ ((x:1;y:-2),(x:2;y:-1),(x:2;y:1),(x:1;y:2) (x:-1;y:2),(x:-2;y:1),(x:-2;y:-1),(x:-1;y:-2));\n\nchar increments[8][2] =\n\n{\n\n1, -2, 2, -1, 2, 1, 1, 2,\n\n-1, 2, -2, 1, -2, -1, -1, -2\n\n};\n\nvoid next_step(char pos, char steps[])  \/\/ \u628a\u4f4d\u7f6e\u5728pos\u5e8f\u53f7\u7684\u70b9\u7684\u6bcf\u4e00\u4e2a\u4e0b\u4e00\u4e2a\u53ef\u9009\u4f4d\u7f6e\u8bb0\u5728\u6570\u7ec4\u4e2d\u3002\n\n{\n\nchar valid_count = 0;\n\ncoordinate co = serial_num2coordinate(pos);\n\ncoordinate tmp;\n\nchar serial_num;\n\nfor ( int i = 0; i &lt; 8; i++ )\n\n{\n\ntmp._x = co._x + increments[i][0];\n\ntmp._y = co._y + increments[i][1];\n\nif ( tmp._x &lt; 0 || tmp._x &gt;= ROW_NUM || tmp._y &lt; 0 || tmp._y &gt;= COLUMN_NUM )  \/\/ \u4fdd\u8bc1\u4f4d\u7f6e\u6709\u6548\n\n{\n\ncontinue;\n\n}\n\nserial_num = coordinate2serial_num(tmp);\n\nif ( serial_num &gt;= 1 &amp;&amp; serial_num &lt;= ELEM_COUNT )\n\n{\n\nvalid_count++;\n\nsteps[valid_count] = serial_num;\n\n}\n\nelse\n\n{\n\ncerr &lt;&lt; &quot;Not expected to reach here.\\n&quot;;\n\n}\n\n}\n\nsteps[0] = valid_count;\n\n}\n\n\n\n\/\/ \u4e0b\u9762\u7684\u903b\u8f91\u4ee5\u6bcf\u4e2a\u70b9\u7684\u4e0b\u4e00\u6b65\u53ef\u8df3\u70b9\u7684\u6570\u76ee\u4f5c\u4e3a\u6743\u91cd\u6392\u5e8f\u3002\n\nstruct pos_weight\n\n{\n\nchar _pos;\n\nchar _weight;\n\n};\n\n\/\/ \u53c8\u662f\u7528\u9012\u5f52\u3002\u8fd9\u91cc\u4e3a\u4e86\u5b9e\u73b0\u5feb\u901f\u6392\u5e8f\n\nint partition(pos_weight poses[], int low, int high)\n\n{\n\npos_weight pivot = poses[low];\n\nwhile (low &lt; high)\n\n{\n\nwhile (low &lt; high &amp;&amp; pivot._weight &lt; poses[high]._weight)\n\nhigh--;\n\nposes[low] = poses[high];\n\nwhile (low &lt; high &amp;&amp; pivot._weight &gt;= poses[low]._weight)\n\nlow++;\n\nposes[high] = poses[low];\n\n}\n\nposes[low] = pivot;\n\nreturn low;\n\n}\n\n\/\/ \u5feb\u901f\u6392\u5e8f\u3002\n\nvoid quick_sort_steps(pos_weight poses[], int low, int high)\n\n{\n\nif ( low &lt; high )\n\n{\n\nint pivot_loc = partition(poses, low, high);\n\nquick_sort_steps(poses, low, pivot_loc-1);\n\nquick_sort_steps(poses, pivot_loc+1, high);\n\n}\n\n}\n\nvoid rearrage_steps(char poses[], int len) \/\/ poese\u91cc\u653e\u7f6e\u4e86\u4e0b\u4e00\u4e2a\u4f4d\u7f6e\u6570\u7ec4\u3002Len\u662f\u6570\u7ec4\u957f\u5ea6\u3002\n\n{\n\nchar weight, pos, next_step_count;\n\nvector&lt;pos_weight&gt; vec(len);\n\nfor ( int i = 0; i &lt; len; i++ ) \/\/ \u8ba1\u7b97\u6743\u91cd.\n\n{\n\nweight = 0;\n\npos = poses[i];\n\nnext_step_count = elocution[pos-1][0];\n\nfor ( int j = 0; j &lt; next_step_count; j++ )\n\n{\n\nchar next_step_pos = elocution[pos-1][j+1];\n\nif ( 0 == stamps[next_step_pos-1] )\n\n{\n\nweight++;  \/\/ \u5982\u679c\u6709\u4e00\u4e0b\u4e00\u8df3\u70b9\u6ca1\u8d70\u8fc7\u5219\u6743\u91cd\u52a01.\n\n}\n\n}\n\nvec[i]._pos = pos;\n\nvec[i]._weight = weight;\n\n}\n\nquick_sort_steps(&amp;vec[0], 0, len-1);  \/\/ \u6839\u636e\u6743\u91cd\u6392\u5e8f.\n\nfor ( int i = 0; i &lt; len; i++ ) \/\/ \u628a\u6392\u5e8f\u540e\u7684\u4f4d\u7f6e\u5199\u56de\u539f\u59cb\u6570\u7ec4.\n\n{\n\nposes[i] = vec[i]._pos;\n\n}\n\n}\n\n\n\nvoid init_elocution()\n\n{\n\nmemset(stamps, 0, sizeof(stamps));\n\nfor ( int i = 1; i &lt;= ELEM_COUNT; i++ )\n\n{\n\nnext_step(i, elocution[i-1]);\n\n}\n\n}\n\n\n\nchar track[ELEM_COUNT];\n\nvoid run_horse(char start_pos, char step_count) \/\/ step_count [0 -- 64)\n\n{\n\n\/\/ \u5982\u679c\u5df2\u7ecf\u7ecf\u8fc7\u8fd9\u70b9\u5c31\u7acb\u5373\u9000\u51fa\u51fd\u6570\u3002\n\nif ( 1 == stamps[start_pos-1] )\n\n{\n\nreturn;\n\n}\n\n\n\ntrack[step_count] = start_pos;\n\n\n\nif ( step_count == COLUMN_NUM * ROW_NUM - 1 )  \/\/ \u662f\u4e0d\u662f\u6700\u540e\u4e00\u6b65\u3002\n\n{\n\nfor ( int i = 0; i &lt; sizeof(track); i++ )\n\n{\n\ncout &lt;&lt; (int)track[i];\n\nif ( i + 1 != sizeof(track) )\n\n{\n\ncout &lt;&lt; &quot; &quot;;\n\n}\n\n}\n\ncout &lt;&lt; endl;\n\nlongjmp(jmpbuffer, 0x1);\n\nreturn;\n\n}\n\n\n\n\/\/ \u8bb0\u4e0b\u5df2\u7ecf\u8d70\u4e86\u8fd9\u4e00\u6b65\u3002\n\nstamps[start_pos-1] = 1;   rearrage_steps(elocution[start_pos-1]+1, elocution[start_pos-1][0]);\n\nfor ( int i = 0; i &lt; elocution[start_pos-1][0]; i++ )\n\n{\n\nrun_horse(elocution[start_pos-1][i+1], step_count+1);\n\n}\n\nstamps[start_pos-1] = 0;  \/\/ \u8bd5\u5b8c\u4e86\u6240\u6709\u53ef\u8d70\u6b65.\u9000\u51fa\u8fd9\u4e2a\u51fd\u6570.\u91cd\u7f6e\u8fd9\u4e2a\u4f4d\u7f6e\u4e3a\u6ca1\u6709\u8d70\u8fc7\u3002\n\n}\n\n\n\nint main(int argc, char* argv[])\n\n{\n\nint pos;\n\nvector&lt;int&gt; vec;\n\n\n\nwhile(true)\n\n{\n\ncin &gt;&gt; pos;\n\nif (pos==-1)\n\n{\n\nbreak;\n\n}\n\nvec.push_back(pos);\n\n}\n\n\n\nfor ( int i = 0; i &lt; vec.size(); i++ )\n\n{\n\nif(setjmp(jmpbuffer) == 0)  \/\/ \u4e3a\u4e86\u5f88\u6df1\u7684\u9012\u5f52\u51fd\u6570\u5feb\u901f\u56de\u9000\u5230\u8fd9\u91cc\u3002\n\n{\n\ninit_elocution();\n\nmemset(track, 0, sizeof(track));\n\nmemset(stamps, 0, sizeof(stamps));\n\nrun_horse(vec[i], 0);\n\n}\n\n}\n\n\n\nreturn 0;\n\n}\n\n<\/pre>\n<p>&nbsp;<\/p>\n<\/p><\/div>\n<div>\uff086\uff09\u8be5\u7b97\u6cd5\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662f O(8 ^ (m * n)) &nbsp; m,n\u5206\u522b\u4e3a\u68cb\u76d8\u7684\u957f\u548c\u5bbd\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \u539f\u9898\u76ee\u5982\u4e0b:<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>1153. \u9a6c\u7684\u5468\u6e38\u95ee\u9898<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Description<\/div>\n<div>&nbsp;<\/div>\n<div>\u548c\u9898\u76eeC\u540c\u6837\u7684\u4efb\u52a1\uff0c\u8fd9\u91cc\u53ea\u662f\u628a\u68cb\u76d8\u6269\u5927\u5230\u6807\u51c6\u7684\u56fd\u9645\u8c61\u68cb\u3002\u5bf9\u8fd9\u6837\u4e00\u4e2a8 * 8\u7684\u68cb\u76d8\u7528\u540c\u6837\u7684\u65b9\u6cd5\u7f16\u53f7\u5982\u4e0b\uff1a<\/div>\n<div>&nbsp;<\/div>\n<div>1 &nbsp; &nbsp; 2 &nbsp; &nbsp; 3 &nbsp; &nbsp; &nbsp; 4 &nbsp; &nbsp; 5 &nbsp; &nbsp; 6 &nbsp; &nbsp; &nbsp; 7 &nbsp; &nbsp; 8<\/div>\n<div>&nbsp;<\/div>\n<div>9 &nbsp; &nbsp; 10 &nbsp; &nbsp; &nbsp; 11 &nbsp; &nbsp;12 &nbsp; &nbsp; &nbsp; 13 &nbsp; &nbsp;14 &nbsp; &nbsp; &nbsp; 15 &nbsp; &nbsp;16<\/div>\n<div>&nbsp;<\/div>\n<div>17 &nbsp; &nbsp;18 &nbsp; &nbsp; &nbsp; 19 &nbsp; &nbsp;20 &nbsp; &nbsp; &nbsp; 21 &nbsp; &nbsp;22 &nbsp; &nbsp; &nbsp; 23 &nbsp; &nbsp;24<\/div>\n<div>&nbsp;<\/div>\n<div>25 &nbsp; &nbsp;26 &nbsp; &nbsp; &nbsp; 27 &nbsp; &nbsp;28 &nbsp; &nbsp; &nbsp; 29 &nbsp; &nbsp;30 &nbsp; &nbsp; &nbsp; 31 &nbsp; &nbsp;32<\/div>\n<div>&nbsp;<\/div>\n<div>33 &nbsp; &nbsp;34 &nbsp; &nbsp; &nbsp; 35 &nbsp; &nbsp;36 &nbsp; &nbsp; &nbsp; 37 &nbsp; &nbsp;38 &nbsp; &nbsp; &nbsp; 39 &nbsp; &nbsp;40<\/div>\n<div>&nbsp;<\/div>\n<div>41 &nbsp; &nbsp;42 &nbsp; &nbsp; &nbsp; 43 &nbsp; &nbsp;44 &nbsp; &nbsp; &nbsp; 45 &nbsp; &nbsp;46 &nbsp; &nbsp; &nbsp; 47 &nbsp; &nbsp;48<\/div>\n<div>&nbsp;<\/div>\n<div>49 &nbsp; &nbsp;50 &nbsp; &nbsp; &nbsp; 51 &nbsp; &nbsp;52 &nbsp; &nbsp; &nbsp; 53 &nbsp; &nbsp;54 &nbsp; &nbsp; &nbsp; 55 &nbsp; &nbsp;56<\/div>\n<div>&nbsp;<\/div>\n<div>57 &nbsp; &nbsp;58 &nbsp; &nbsp; &nbsp; 59 &nbsp; &nbsp;60 &nbsp; &nbsp; &nbsp; 61 &nbsp; &nbsp;62 &nbsp; &nbsp; &nbsp; 63 &nbsp; &nbsp;64<\/div>\n<div>&nbsp;<\/div>\n<div>Input<\/div>\n<div>&nbsp;<\/div>\n<div>\u8f93\u5165\u6709\u82e5\u5e72\u884c\u3002\u6bcf\u884c\u4e00\u4e2a\u6574\u6570N(1&lt;=N&lt;=64)\uff0c\u8868\u793a\u9a6c\u7684\u8d77\u70b9\u3002\u6700\u540e\u4e00\u884c\u7528-1\u8868\u793a\u7ed3\u675f\uff0c\u4e0d\u7528\u5904\u7406\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>Output<\/div>\n<div>&nbsp;<\/div>\n<div>\u5bf9\u8f93\u5165\u7684\u6bcf\u4e00\u4e2a\u8d77\u70b9\uff0c\u6c42\u4e00\u6761\u5468\u6e38\u7ebf\u8def\u3002\u5bf9\u5e94\u5730\u8f93\u51fa\u4e00\u884c\uff0c\u670964\u4e2a\u6574\u6570\uff0c\u4ece\u8d77\u70b9\u5f00\u59cb\u6309\u987a\u5e8f\u7ed9\u51fa\u9a6c\u6bcf\u6b21\u7ecf\u8fc7\u7684\u68cb\u76d8\u65b9\u683c\u7684\u7f16\u53f7\u3002\u76f8\u90bb\u7684\u6570\u5b57\u7528\u4e00\u4e2a\u7a7a\u683c\u5206\u5f00\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>Sample Input<\/div>\n<div>&nbsp;<\/div>\n<div>4<\/div>\n<div>-1<\/div>\n<div>Sample Output<\/div>\n<div>&nbsp;<\/div>\n<div>\u6ce8\u610f\uff1a\u5982\u679c\u8d77\u70b9\u548c\u8f93\u5165\u7ed9\u5b9a\u7684\u4e0d\u540c\uff0c\u91cd\u590d\u591a\u6b21\u7ecf\u8fc7\u540c\u4e00\u65b9\u683c\u6216\u8005\u6709\u7684\u65b9\u683c\u6ca1\u6709\u88ab\u7ecf\u8fc7\uff0c\u90fd\u4f1a\u88ab\u8ba4\u4e3a\u662f\u9519\u8bef\u7684\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5509\uff01\uff01\uff01 \u4e0a\u6b21\u4ea4\u4f5c\u4e1a\u5199\u9519\u9898\u76ee\u4e86\uff0c\u505a\u4e86\u7b80\u5355\u7684\u9a6c\u5468\u6e38 sicily 1152\u3002\u8865\u4e0a\u65b0\u7684,\u5e94\u8be5\u662fsicily 1153.\u4e3a\u4e86\u89e3\u51b3\u89c4\u6a21\u592a\u5927\u7684\u95ee\u9898\u3002\u52a0\u4e0a\u4e86\u4f18\u5316\u7b97\u6cd5\u3002 &nbsp; \u4e2d\u5927ACM\u5b9e\u9a8c\u9898\u3002 &nbsp; \uff081\uff09\u539f\u9898\u4e2d\u6587\u5927\u610f &nbsp; \u4e2d\u56fd\u8c61\u68cb\u7684\u9a6c\u6309\u7167\u8c61\u68cb\u7684\u89c4\u5219\u57288 x 8 \u7684\u68cb\u76d8\u4e0a\u8dd164\u6b65\u8dd1\u5b8c\u6240\u6709\u7684\u683c\u5b50\u3002 &nbsp; &nbsp; &nbsp; \uff082\uff09\u7b97\u6cd5\u601d\u60f3\u53ca\u89e3\u9898\u7528\u5230\u7684\u4e3b\u8981\u6570\u636e\u7ed3\u6784 &nbsp; &nbsp; &nbsp; \u4ece\u6bcf\u4e00\u4e2a\u70b9\u5f80\u4e0b\u8d70\u7b2c\u4e8c\u6b65\uff0c\u4f1a\u6709\u51e0\u70b9\u6709\u6548\u7684\u884c\u8d70\u4f4d\u7f6e\u3002 \u628a\u5f53\u524d\u4f4d\u7f6e\u8bb0\u5728\u6808\u91cc\u9762\uff0c\u4ee5\u6df1\u5ea6\u4f18\u5148\u7684\u65b9\u5f0f\u8fdb\u5165\u4e0b\u4e00\u4e2a\u6709\u6548\u4f4d\u7f6e\u3002\u5982\u679c\u4e0b\u4e00\u4e2a\u6709\u6548\u4f4d\u7f6e\u5728\u4e4b\u524d\u5df2\u7ecf\u8d70\u8fc7\uff0c\u5219\u4ece\u6808\u9876\u5f39\u51fa\u4e0a\u4e00\u4f4d\u7f6e\uff0c\u6062\u590d\u5230\u8c03\u51fa\u7684\u4f4d\u7f6e\u540e\u5c1d\u8bd5\u672a\u8d70\u8fc7\u7684\u6709\u6548\u4f4d\u7f6e\u3002\u5229\u7528\u51fd\u6570\u8c03\u7528\u65f6\u4f1a\u538b\u6808\u7684\u7279\u522b\uff0c\u7528\u51fd\u6570\u9012\u5f52\u8c03\u7528\u5373\u53ef\u89e3\u51b3\u95ee\u9898\u3002 &nbsp; \u8f6f\u4e4b\u7b80\u5355\u7684\u9a6c\u5468\u6e38\uff0c8 x 8 \u68cb\u76d8\u7684\u89c4\u6a21\u975e\u5e38\u5927\u3002\u9700\u8981\u5728\u53ef\u9009\u4e0b\u4e00\u6b65\u4e2d\u627e\u5230\u6700\u63a5\u8fd1\u6b63\u786e\u8def\u7ebf\u7684\u70b9\u3002\u6c42\u8be5\u70b9\u7684\u529e\u6cd5\u662f\u628a\u6240\u4ee5\u7684\u53ef\u9009\u70b9\u5148\u627e\u51fa\uff0c\u518d\u7ed9\u8fd9\u4e9b\u53ef\u9009\u70b9\u6309\u6743\u91cd\u6392\u5e8f\uff0c\u4ece\u6700\u4f18\u7684\u89e3\u4f9d\u6b21\u5411\u6b21\u4f18\uff0c\u6b21\u6b21\u4f18&#8230;..\u7684\u70b9\u8bd5\u63a2\u3002\u91cd\u70b9\u5728\u6743\u91cd\u7684\u7b97\u6cd5\u3002\u8fd9\u91cc\u7684\u6743\u91cd\u7684\u8ba1\u7b97\u6cd5\u5219\u662f\u6307\u4e00\u4e2a\u70b9\u7684\u4e0b\u4e00\u6b21\u53ef\u8d70\u7684\u70b9\u7684\u4e2a\u6570\u3002 &nbsp; \u4e3b\u8981\u7684\u6570\u636e\u7ed3\u6784\u6709\uff1a &nbsp; \/\/ elocution\u6570\u7ec4\u5728\u521d\u59cb\u5316\u540e\u4f1a\u8bb0\u4e0b\u6bcf\u4e2a\u6709\u6548\u4f4d\u7f6e\u7684\u4e0b\u4e00\u6b65\u6709\u54ea\u4e9b\u53ef\u8d70\u4f4d \/\/ \u7f6e.elocution[x][0]\u7528\u4e0b\u68070\u8bb0\u4e2a\u6570\u3002\u6700\u591a8\u4e2a\u6709\u6548\u53ef\u8d70\u4f4d\u7f6e\u3002 char elocution[ELEM_COUNT][9]; \/\/ stamps\u6570\u7ec4\u8bb0\u6bcf\u4e2a\u70b9\u662f\u5426\u5df2\u7ecf\u8d70\u8fc7\u4e86\u30020\u8868\u793a\u6ca1\u8d70\u8fc7\uff0c1\u8868\u793a\u8d70\u8fc7\u4e86\u3002 char stamps[ELEM_COUNT]; \/\/ track\u6570\u7ec4\u8bb0\u8def\u5f84\u7684\u987a\u5e8f\u3002 char track[ELEM_COUNT]; \u901a\u8fc7\u7ed3\u5408stamps\u6570\u7ec4\u548celocution\u6570\u7ec4\u53ef\u4ee5\u7b97\u51fa\u4e0b\u4e00\u6b65\u7684\u6bcf\u4e2a\u70b9\u7684\u6743\u91cd\u3002 \uff083\uff09\u8be6\u7ec6\u89e3\u9898\u601d\u8def 1. \u5148\u521d\u59cb\u5316\u4e00\u5f20\u8868\u3002\u8fd9\u5f20\u8868\u8bb0\u4e0b\u4e86\u68cb\u76d8\u4e0a\u6240\u6709\u768430\u4e2a\u4f4d\u7f6e\u7684\u4e0b\u4e00\u6b65\u53ef\u8d70\u7684\u6709\u6548\u4f4d\u7f6e. 2. \u5199\u4e00\u4e2a\u4e00\u822c\u7684\u9012\u5f52\u8c03\u7528\u81ea\u5df1\u7684\u51fd\u6570\uff0c\u8868\u793a\u9a6c\u5728\u8d70\u7b2c\u51e0\u6b65\u65f6\u5230\u4e86\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u7136\u540e\u6c42\u51fa\u4f59\u4e0b\u7684\u6240\u6709\u53ef\u8d70\u4f4d\u7f6e\u3002 3. \u4f59\u4e0b\u7684\u6240\u6709\u4f4d\u7f6e\u6309\u7167\u4e0a\u6587\u63d0\u5230\u7684\u6743\u91cd\u6392\u5e8f\u3002 4. \u5bf9\u4e8e\u6392\u5e8f\u540e\u7684\u53ef\u9009\u70b9\u6570\u7ec4\uff0c\u6309\u987a\u5e8f\u4f9d\u6b21\u7528\u9012\u5f52\u51fd\u6570\u5c1d\u8bd5\u3002 &hellip; <a href=\"https:\/\/ykyi.net\/?p=252\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u71ac\u591c\u5b8c\u6210 sicily1153 \u9a6c\u5468\u6e38\u89e3\u9898\u62a5\u544a\u3002\u56f0\u6b7b\u54e5\u4e86.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[108],"class_list":["post-252","post","type-post","status-publish","format-standard","hentry","category-tech_articles","tag-108"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=252"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/252\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}