{"id":339,"date":"2011-12-26T13:12:28","date_gmt":"2011-12-26T05:12:28","guid":{"rendered":"http:\/\/ykyi.net\/?p=339"},"modified":"2011-12-26T13:12:28","modified_gmt":"2011-12-26T05:12:28","slug":"sicily-1031-campus-%e8%a7%a3%e9%a2%98%e6%8a%a5%e5%91%8a","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=339","title":{"rendered":"Sicily 1031 Campus \u89e3\u9898\u62a5\u544a."},"content":{"rendered":"<div>\n<p>&nbsp;<\/p>\n<div>1 \u539f\u9898\u4e2d\u6587\u5927\u610f;<\/div>\n<div>&nbsp;<\/div>\n<div>Sicily 1031 Campus\u5b9e\u9645\u4e0a\u5c31\u662f\u6c42\u4e00\u4e2a\u56fe\u4e2d\u7ed9\u51fa\u4e24\u70b9\u7684\u6700\u77ed\u8def\u5f84\u7684\u95ee\u9898\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>2 \u7b97\u6cd5\u601d\u60f3\u53ca\u89e3\u9898\u7528\u5230\u7684\u4e3b\u8981\u6570\u636e\u7ed3\u6784;<\/div>\n<div>&nbsp;<\/div>\n<div>\u7528 dijkstra \u7b97\u6cd5\u6c42\u7ed9\u5b9a\u4e24\u70b9\u7684\u6700\u77ed\u8def\u5f84.<\/div>\n<div>&nbsp;<\/div>\n<div>\u6309\u8def\u5f84\u957f\u5ea6\u9012\u589e\u6b21\u5e8f\u4ea7\u751f\u6700\u77ed\u8def\u5f84\u7b97\u6cd5\uff1a \u3000\u3000\u628aV\u5206\u6210\u4e24\u7ec4\uff1a \u3000\u3000\uff081\uff09S\uff1a\u5df2\u6c42\u51fa\u6700\u77ed\u8def\u5f84\u7684\u9876\u70b9\u7684\u96c6\u5408 \u3000\u3000\uff082\uff09V-S=T\uff1a\u5c1a\u672a\u786e\u5b9a\u6700\u77ed\u8def\u5f84\u7684\u9876\u70b9\u96c6\u5408 \u3000\u3000\u5c06T\u4e2d\u9876\u70b9\u6309\u6700\u77ed\u8def\u5f84\u9012\u589e\u7684\u6b21\u5e8f\u52a0\u5165\u5230S\u4e2d\uff0c \u3000\u3000\u4fdd\u8bc1\uff1a\uff081\uff09\u4ece\u6e90\u70b9V0\u5230S\u4e2d\u5404\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u90fd\u4e0d\u5927\u4e8e \u3000\u3000\u4eceV0\u5230T\u4e2d\u4efb\u4f55\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000\uff082\uff09\u6bcf\u4e2a\u9876\u70b9\u5bf9\u5e94\u4e00\u4e2a\u8ddd\u79bb\u503c \u3000\u3000S\u4e2d\u9876\u70b9\uff1a\u4eceV0\u5230\u6b64\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000T\u4e2d\u9876\u70b9\uff1a\u4eceV0\u5230\u6b64\u9876\u70b9\u7684\u53ea\u5305\u62ecS\u4e2d\u9876\u70b9\u4f5c\u4e2d\u95f4 \u3000\u3000\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000\u4f9d\u636e\uff1a\u53ef\u4ee5\u8bc1\u660eV0\u5230T\u4e2d\u9876\u70b9Vk\u7684\u6700\u77ed\u8def\u5f84\uff0c\u6216\u662f\u4eceV0\u5230Vk\u7684 \u3000\u3000\u76f4\u63a5\u8def\u5f84\u7684\u6743\u503c\uff1b\u6216\u662f\u4eceV0\u7ecfS\u4e2d\u9876\u70b9\u5230Vk\u7684\u8def\u5f84\u6743\u503c\u4e4b\u548c\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>3 &nbsp;\u9010\u6b65\u6c42\u7cbe\u7b97\u6cd5\u63cf\u8ff0<\/div>\n<div>&nbsp;<\/div>\n<div>\u7528\u90bb\u63a5\u77e9\u9635\u5b58\u653e\u56fe.1. \u521d\u4f7f\u65f6\u4ee4 S={V0},T={\u5176\u4f59\u9876\u70b9}\uff0cT\u4e2d\u9876\u70b9\u5bf9\u5e94\u7684\u8ddd\u79bb\u503c \u3000\u3000\u82e5\u5b58\u5728&lt;V0,Vi&gt;\uff0cd(V0,Vi)\u4e3a&lt;V0,Vi&gt;\u5f27\u4e0a\u7684\u6743\u503c \u3000\u3000\u82e5\u4e0d\u5b58\u5728&lt;V0,Vi&gt;\uff0cd(V0,Vi)\u4e3a&prop; \u3000\u30002. \u4eceT\u4e2d\u9009\u53d6\u4e00\u4e2a\u5176\u8ddd\u79bb\u503c\u4e3a\u6700\u5c0f\u7684\u9876\u70b9W\u4e14\u4e0d\u5728S\u4e2d\uff0c\u52a0\u5165S \u3000\u30003. \u5bf9T\u4e2d\u9876\u70b9\u7684\u8ddd\u79bb\u503c\u8fdb\u884c\u4fee\u6539\uff1a\u82e5\u52a0\u8fdbW\u4f5c\u4e2d\u95f4\u9876\u70b9\uff0c\u4eceV0\u5230Vi\u7684 \u3000\u3000\u8ddd\u79bb\u503c\u6bd4\u4e0d\u52a0W\u7684\u8def\u5f84\u8981\u77ed\uff0c\u5219\u4fee\u6539\u6b64\u8ddd\u79bb\u503c \u3000\u3000\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa42\u30013\uff0c\u76f4\u5230S\u4e2d\u5305\u542b\u6240\u6709\u9876\u70b9\uff0c\u5373S=T\u4e3a\u6b62<\/div>\n<div>&nbsp;<\/div>\n<div>3 \u7a0b\u5e8f\u6ce8\u91ca\u6e05\u5355 \/\/ \u8fd9\u4efd\u4ee3\u7801\u901a\u4e0d\u8fc7sicily\u3002\u6709case\u9519\u8bef\u3002\u6211\u5b9e\u5728\u627e\u4e0d\u5230\u539f\u56e0\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>\n<pre class=\"brush:cpp\">#include &lt;map&gt;\n\n#include &lt;vector&gt;\n\n#include &lt;string&gt;\n\n#include &lt;iostream&gt;\n\n#include &lt;cstdlib&gt;\n\n#include &lt;cstdio&gt;\n\n#include &lt;cstring&gt;\n\n#include &lt;cassert&gt;\n\n\n\n#define INFINITE 0x0FFFFFFF\n\n\n\n\/\/ \u8fd9\u4e2a\u7c7b\u7684\u51fd\u6570\u51e0\u4e4e\u4e0d\u505a\u53c2\u6570\u6709\u6548\u6027\u7684\u68c0\u67e5.\n\nclass graph_t\n\n{\n\npublic:\n\n\/\/ \u6784\u5efa\u4e00\u4e2a num x num \u7684\u90bb\u63a5\u77e9\u9635\n\ngraph_t(int num)\n\n{\n\nm_matrix = new int[num*num];\n\nm_sunit = new bool[num];\n\nm_spath_table = new int[num];\n\n\/\/ memset(m_matrix, INFINITE, num*num);  \/\/ INFINITE \u8868\u793a\u65e0\u7a77\u8fdc.\n\nfor ( int i = 0; i &lt; num*num; i++ )\n\n{\n\nm_matrix[i] = INFINITE;\n\n}\n\nm_num = num;\n\n}\n\n\n\n\/\/ row,column \u53d6 [0, m_num)\n\nint&amp; operator()(int row, int column)\n\n{\n\nreturn m_matrix[row * m_num + column];\n\n}\n\n\n\n\/\/ vtx_start, vtx_end \u53d6 [vtx_start, vtx_end)\n\nint shortestpath_dij(int vtx_start, int vtx_end)\n\n{\n\ninit_dij(vtx_start);  \/\/ \u521d\u59cb\u5316dijkstra\u7b97\u6cd5\u9700\u8981\u7684\u4e00\u4e9b\u6570\u636e.\n\n\n\nif ( vtx_end == vtx_start )\n\n{\n\nreturn this-&gt;operator()(vtx_start, vtx_end);\n\n}\n\n\n\n\/\/ \u8fd8\u5269 m_num - 1 \u4e2a\u70b9.\n\nfor ( int i = 1; i &lt; m_num; i++ )\n\n{\n\n\/\/ \u627e\u4e0b\u4e00\u4e2a\u6700\u8fd1\u7684\u70b9.\n\nint vtx = -1, min = INFINITE;\n\nfor ( int j = 0; j &lt; m_num; j++ )\n\n{\n\nif ( m_sunit[j] )  \/\/ \u8fd9\u4e2a\u70b9\u5df2\u7ecf\u5728\u5df2\u7ecf\u6c42\u5f97\u6700\u77ed\u8def\u5f84\u7684\u70b9\u7684\u96c6\u5408\u4e2d\u4e86.\n\ncontinue;\n\n\n\nif ( m_spath_table[j] &lt; min )\n\n{\n\nvtx = j;\n\nmin = m_spath_table[j];\n\n}\n\n}\n\n\/\/ \u5df2\u7ecf\u6ca1\u6709\u8fde\u901a\u7684\u9876\u70b9\u4e86.\n\nif ( vtx == -1 )\n\n{\n\nreturn -1;\n\n}\n\nm_sunit[vtx] = true;  \/\/ \u628a\u8fd9\u4e2a\u70b9\u52a0\u5165\u96c6\u5408\u4e2d.\n\n\n\n\/\/ \u8fd9\u4e2a\u70b9\u662f\u7ec8\u70b9.  http:\/\/ykyi.net\n\nif ( vtx == vtx_end )\n\n{\n\nreturn min;\n\n}\n\n\n\n\/\/ \u56e0\u4e3a\u627e\u5230\u4e86\u4e00\u4e2a\u65b0\u7684\u70b9\u52a0\u5165\u4e86\u96c6\u5408\uff0c\u66f4\u65b0\u6700\u77ed\u8def\u5f84\u8868.\n\nfor ( int k = 0; k &lt; m_num; k++ )\n\n{\n\nif ( m_sunit[k] )\n\ncontinue;\n\n\n\nif (  min + this-&gt;operator()(vtx, k) &lt; m_spath_table[k] )\n\n{\n\nm_spath_table[k] = min + this-&gt;operator()(vtx, k);\n\n}\n\n}\n\n}\n\n\n\nassert(0); \/\/ it&#39;s not suppossed to reach here.\n\nreturn -1;\n\n}\n\n\n\n~graph_t()\n\n{\n\ndelete m_matrix;\n\ndelete m_sunit;\n\ndelete m_spath_table;\n\n}\n\n\n\nprivate:\n\nvoid init_dij(int vtx_start)\n\n{\n\nmemset(m_sunit, 0, m_num);   \/\/ \u521d\u59cb\u5316\u4e3a\u6ca1\u6709\u70b9\u52a0\u5165\u8fd9\u4e2a\u5df2\u6c42\u5f97\u6700\u77ed\u8def\u5f84\u7684\u7ec8\u70b9\u96c6\u5408.\n\nfor ( int i = 0; i &lt; m_num; i++ )\n\n{\n\nm_spath_table[i] = this-&gt;operator()(vtx_start, i);\n\n}\n\nassert( 0 == m_spath_table[vtx_start] );\n\nm_sunit[vtx_start] = true;\n\n}\n\n\n\nprivate:\n\nint   m_num;\n\nint*  m_matrix;  \/\/ \u5b58\u90bb\u63a5\u77e9\u9635\n\nbool* m_sunit;   \/\/ \u5728dijkstra\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u7528\u6765\u5b58\u67d0\u70b9\u662f\u5426\u5df2\u7ecf\u662f\u6700\u77ed\u8def\u5f84\u4e2d\u7684\u70b9.\n\nint*  m_spath_table;  \/\/ \u5728dijkstra\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u5b58\u5230\u67d0\u70b9\u662f\u7684\u6700\u77ed\u8def\u5f84\u662f\u591a\u5c11.\n\n};\n\n\n\n\n\nint main(int argc, char* argv[])\n\n{\n\nint case_count, path_count, weight, next_ava_vtx;\n\nint vtx_start, vtx_end;\n\nstd::map&lt;std::string, int&gt; loc2vtx;  \/\/ \u5b58\u5730\u70b9\u5b57\u7b26\u4e32\u5230\u56fe\u7684\u9876\u70b9\u53f7\u7684\u6620\u5c04.\n\nstd::vector&lt;int&gt; spirit;\n\nstd::string line;\n\n\n\nstd::cin &gt;&gt; case_count;\n\nfor ( int i = 0; i &lt; case_count; i++ )\n\n{\n\nloc2vtx.clear();\n\nspirit.clear();\n\nnext_ava_vtx = 0;\n\n\n\nstd::cin &gt;&gt; path_count;\n\nfor ( int j = 0; j &lt; path_count; j++ )\n\n{\n\n\/\/ \u5f97\u5230\u8d77\u70b9\u5730\u5740\u5b57\u7b26\u4e32.\n\nstd::cin &gt;&gt; line;\n\nstd::map&lt;std::string, int&gt;::iterator ite = loc2vtx.find(line);\n\nif ( loc2vtx.end() != ite )\n\n{\n\nvtx_start = ite-&gt;second;\n\n}\n\nelse\n\n{\n\nvtx_start = next_ava_vtx;\n\nloc2vtx[line] = vtx_start;\n\nnext_ava_vtx++;\n\n}\n\nspirit.push_back(vtx_start);\n\n\n\n\/\/ \u5f97\u5230\u7ec8\u70b9\u5730\u5740\u5b57\u7b26\u4e32.\n\nstd::cin &gt;&gt; line;\n\nite = loc2vtx.find(line);\n\nif ( loc2vtx.end() != ite )\n\n{\n\nvtx_end = ite-&gt;second;\n\n}\n\nelse\n\n{\n\nvtx_end = next_ava_vtx;\n\nloc2vtx[line] = vtx_end;\n\nnext_ava_vtx++;\n\n}\n\nspirit.push_back(vtx_end);\n\n\n\n\/\/ \u5f97\u5230\u6743\u91cd\n\nstd::cin &gt;&gt; weight;\n\nspirit.push_back(weight);\n\n}\n\n\n\n\/\/ \u81f3\u6b64 next_ava_vtx \u4e2d\u5b58\u653e\u7684\u5b9e\u9645\u4e0a\u662f\u90bb\u63a5\u65b9\u9635\u7684\u9636.\n\ngraph_t graph(next_ava_vtx);\n\nfor ( int i = 0; i &lt; spirit.size()\/3; i++ )\n\n{\n\nint x = spirit[3*i];\n\nint y = spirit[3*i+1];\n\nint w = spirit[3*i+2];\n\ngraph(x, y) = w;\n\ngraph(y, x) = w;\n\n}\n\nfor ( int i = 0; i &lt; next_ava_vtx; i++ )\n\n{\n\ngraph(i, i) = 0;\n\n}\n\n\n\nstd::cin &gt;&gt; line;\n\nstd::map&lt;std::string, int&gt;::iterator ite = loc2vtx.find(line);\n\nif ( ite == loc2vtx.end() )\n\n{\n\nstd::cout &lt;&lt; &quot;-1\\n&quot;;\n\ncontinue;\n\n}\n\nvtx_start = loc2vtx[line];\n\n\n\nstd::cin &gt;&gt; line;\n\nite = loc2vtx.find(line);\n\nif ( ite == loc2vtx.end() )\n\n{\n\nstd::cout &lt;&lt; &quot;-1\\n&quot;;\n\ncontinue;\n\n}\n\nvtx_end = loc2vtx[line];\n\n\n\nif ( vtx_start == vtx_end )\n\n{\n\nstd::cout &lt;&lt; &quot;0\\n&quot;;\n\ncontinue;\n\n}\n\n\n\nstd::cout &lt;&lt; graph.shortestpath_dij(vtx_start, vtx_end) &lt;&lt; std::endl;\n\n}\n\n\n\nreturn 0;\n\n}<\/pre>\n<p>&nbsp;<\/p>\n<\/p><\/div>\n<div>&nbsp;<\/div>\n<div>4 \u5bf9\u65f6\u95f4\u590d\u6742\u5ea6\uff0c\u7a7a\u95f4\u590d\u6742\u5ea6\u65b9\u9762\u7684\u5206\u6790\u3001\u4f30\u7b97\u3002<\/div>\n<div>&nbsp;<\/div>\n<div>\u65f6\u95f4\u590d\u6742\u5ea6\u548c\u7a7a\u95f4\u590d\u6742\u5ea6\u90fd\u662fO(n*n). &nbsp; http:\/\/ykyi.net<\/div>\n<div>&nbsp;<\/div>\n<div>\/\/\/\/\/\/\/\/\/\/\/\/\/ \u539f\u9898<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>1031. Campus<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Description<\/div>\n<div>&nbsp;<\/div>\n<div>At present, Zhongshan University has 4 campuses with a total area of 6.17 square kilometers sitting respectively on both sides of the Pearl River or facing the South China Sea. The Guangzhou South Campus covers an area of 1.17 square kilometers, the North Campus covers an area of 0.39 square kilometers, the Guangzhou East Campus has an area of 1.13 square kilometers and the Zhuhai Campus covers an area of 3.48 square kilometers. All campuses have exuberance of green trees, abundance of lawns and beautiful sceneries, and are ideal for molding the temperaments, studying and doing research.<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp;Sometime, the professors and students have to go from one place to another place in one campus or between campuses. They want to find the shortest path between their source place S and target place T. Can you help them?<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Input<\/div>\n<div>&nbsp;<\/div>\n<div>The first line of the input is a positive integer C. C is the number of test cases followed. In each test case, the first line is a positive integer N (0&lt;N&lt;=100) that represents the number of roads. After that, N lines follow. The i-th(1&lt;=i&lt;=N) line contains two strings Si, Ti and one integer Di (0&lt;=Di&lt;=100). It means that there is a road whose length is Di between Si and Ti. Finally, there are two strings S and T, you have to find the shortest path between S and T. S, T, Si(1&lt;=i&lt;=N) and Ti(1&lt;=i&lt;=N) are all given in the following format: str_Campus.str_Place. str_Campus represents the name of the campus, and str_Place represents the place in str_Campus. str_Campus is &quot;North&quot;, &quot;South&quot;, &quot;East&quot; or &quot;Zhuhai&quot;. str_Place is a string which has less than one hundred lowercase characters from &quot;a-z&quot;. You can assume that there is at most one road directly between any two places.<\/div>\n<div>&nbsp;<\/div>\n<div>Output<\/div>\n<div>&nbsp;<\/div>\n<div>The output of the program should consist of C lines, one line for each test case. For each test case, the output is a single line containing one integer. If there is a path between S and T, output the length of the shortest path between them. Otherwise just output &quot;-1&quot; (without quotation mark). No redundant spaces are needed.<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 1 \u539f\u9898\u4e2d\u6587\u5927\u610f; &nbsp; Sicily 1031 Campus\u5b9e\u9645\u4e0a\u5c31\u662f\u6c42\u4e00\u4e2a\u56fe\u4e2d\u7ed9\u51fa\u4e24\u70b9\u7684\u6700\u77ed\u8def\u5f84\u7684\u95ee\u9898\u3002 &nbsp; 2 \u7b97\u6cd5\u601d\u60f3\u53ca\u89e3\u9898\u7528\u5230\u7684\u4e3b\u8981\u6570\u636e\u7ed3\u6784; &nbsp; \u7528 dijkstra \u7b97\u6cd5\u6c42\u7ed9\u5b9a\u4e24\u70b9\u7684\u6700\u77ed\u8def\u5f84. &nbsp; \u6309\u8def\u5f84\u957f\u5ea6\u9012\u589e\u6b21\u5e8f\u4ea7\u751f\u6700\u77ed\u8def\u5f84\u7b97\u6cd5\uff1a \u3000\u3000\u628aV\u5206\u6210\u4e24\u7ec4\uff1a \u3000\u3000\uff081\uff09S\uff1a\u5df2\u6c42\u51fa\u6700\u77ed\u8def\u5f84\u7684\u9876\u70b9\u7684\u96c6\u5408 \u3000\u3000\uff082\uff09V-S=T\uff1a\u5c1a\u672a\u786e\u5b9a\u6700\u77ed\u8def\u5f84\u7684\u9876\u70b9\u96c6\u5408 \u3000\u3000\u5c06T\u4e2d\u9876\u70b9\u6309\u6700\u77ed\u8def\u5f84\u9012\u589e\u7684\u6b21\u5e8f\u52a0\u5165\u5230S\u4e2d\uff0c \u3000\u3000\u4fdd\u8bc1\uff1a\uff081\uff09\u4ece\u6e90\u70b9V0\u5230S\u4e2d\u5404\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u90fd\u4e0d\u5927\u4e8e \u3000\u3000\u4eceV0\u5230T\u4e2d\u4efb\u4f55\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000\uff082\uff09\u6bcf\u4e2a\u9876\u70b9\u5bf9\u5e94\u4e00\u4e2a\u8ddd\u79bb\u503c \u3000\u3000S\u4e2d\u9876\u70b9\uff1a\u4eceV0\u5230\u6b64\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000T\u4e2d\u9876\u70b9\uff1a\u4eceV0\u5230\u6b64\u9876\u70b9\u7684\u53ea\u5305\u62ecS\u4e2d\u9876\u70b9\u4f5c\u4e2d\u95f4 \u3000\u3000\u9876\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6 \u3000\u3000\u4f9d\u636e\uff1a\u53ef\u4ee5\u8bc1\u660eV0\u5230T\u4e2d\u9876\u70b9Vk\u7684\u6700\u77ed\u8def\u5f84\uff0c\u6216\u662f\u4eceV0\u5230Vk\u7684 \u3000\u3000\u76f4\u63a5\u8def\u5f84\u7684\u6743\u503c\uff1b\u6216\u662f\u4eceV0\u7ecfS\u4e2d\u9876\u70b9\u5230Vk\u7684\u8def\u5f84\u6743\u503c\u4e4b\u548c\u3002 &nbsp; 3 &nbsp;\u9010\u6b65\u6c42\u7cbe\u7b97\u6cd5\u63cf\u8ff0 &nbsp; \u7528\u90bb\u63a5\u77e9\u9635\u5b58\u653e\u56fe.1. \u521d\u4f7f\u65f6\u4ee4 S={V0},T={\u5176\u4f59\u9876\u70b9}\uff0cT\u4e2d\u9876\u70b9\u5bf9\u5e94\u7684\u8ddd\u79bb\u503c \u3000\u3000\u82e5\u5b58\u5728&lt;V0,Vi&gt;\uff0cd(V0,Vi)\u4e3a&lt;V0,Vi&gt;\u5f27\u4e0a\u7684\u6743\u503c \u3000\u3000\u82e5\u4e0d\u5b58\u5728&lt;V0,Vi&gt;\uff0cd(V0,Vi)\u4e3a&prop; \u3000\u30002. \u4eceT\u4e2d\u9009\u53d6\u4e00\u4e2a\u5176\u8ddd\u79bb\u503c\u4e3a\u6700\u5c0f\u7684\u9876\u70b9W\u4e14\u4e0d\u5728S\u4e2d\uff0c\u52a0\u5165S \u3000\u30003. \u5bf9T\u4e2d\u9876\u70b9\u7684\u8ddd\u79bb\u503c\u8fdb\u884c\u4fee\u6539\uff1a\u82e5\u52a0\u8fdbW\u4f5c\u4e2d\u95f4\u9876\u70b9\uff0c\u4eceV0\u5230Vi\u7684 \u3000\u3000\u8ddd\u79bb\u503c\u6bd4\u4e0d\u52a0W\u7684\u8def\u5f84\u8981\u77ed\uff0c\u5219\u4fee\u6539\u6b64\u8ddd\u79bb\u503c \u3000\u3000\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa42\u30013\uff0c\u76f4\u5230S\u4e2d\u5305\u542b\u6240\u6709\u9876\u70b9\uff0c\u5373S=T\u4e3a\u6b62 &nbsp; 3 \u7a0b\u5e8f\u6ce8\u91ca\u6e05\u5355 \/\/ \u8fd9\u4efd\u4ee3\u7801\u901a\u4e0d\u8fc7sicily\u3002\u6709case\u9519\u8bef\u3002\u6211\u5b9e\u5728\u627e\u4e0d\u5230\u539f\u56e0\u3002 &nbsp; #include &lt;map&gt; #include &lt;vector&gt; #include &lt;string&gt; &hellip; <a href=\"https:\/\/ykyi.net\/?p=339\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sicily 1031 Campus \u89e3\u9898\u62a5\u544a.&#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":[14,108],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-tech_articles","tag-acm","tag-108"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/339","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=339"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/339\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}