{"id":279,"date":"2023-09-28T00:51:03","date_gmt":"2023-09-27T16:51:03","guid":{"rendered":"https:\/\/www.n-bc.top\/?p=279"},"modified":"2026-08-21T11:44:35","modified_gmt":"2026-08-21T03:44:35","slug":"%e5%8d%95%e6%ba%90%e6%9c%80%e7%9f%ad%e8%b7%af","status":"publish","type":"post","link":"https:\/\/www.n-bc.top\/?p=279","title":{"rendered":"\u5355\u6e90\u6700\u77ed\u8def"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><span style=\"caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif; font-size: 16px; white-space: normal;\">\u7ed9\u51fa\u4e00\u4e2a\u6709\u5411\u56fe\uff0c\u8bf7\u8f93\u51fa\u4ece\u67d0\u4e00\u70b9\u51fa\u53d1\u5230\u6240\u6709\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u3002<\/span><hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"font-size: 16px; white-space: normal; box-sizing: content-box; overflow: visible; height: 0px; margin-top: 2rem; margin-bottom: 2rem; border-width: 0.0625rem 0px 0px; border-color: rgba(0, 0, 0, 0.1) currentcolor currentcolor; border-image-source: none; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\"><\/hr><h4 class=\"wp-block-heading\" id=\"header-id-1\" style=\"white-space: normal; box-sizing: border-box; margin-top: 3rem; margin-bottom: 15px; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif; font-weight: 600; line-height: 1.5; color: rgb(50, 50, 93); font-size: 18px;\">\u8f93\u5165\u683c\u5f0f(Format Input)<\/h4><p style=\"font-size: 16px; white-space: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem; line-height: 1.8; overflow-wrap: break-word; caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\">\u7b2c\u4e00\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570N\u3001M\u3001S\uff0c\u5206\u522b\u8868\u793a\u70b9\u7684\u4e2a\u6570\u3001\u6709\u5411\u8fb9\u7684\u4e2a\u6570\u3001\u51fa\u53d1\u70b9\u7684\u7f16\u53f7\u3002 \u63a5\u4e0b\u6765M\u884c\u6bcf\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570Fi\u3001Gi\u3001Wi\uff0c\u5206\u522b\u8868\u793a\u7b2ci\u6761\u6709\u5411\u8fb9\u7684\u51fa\u53d1\u70b9\u3001\u76ee\u6807\u70b9\u548c\u957f\u5ea6(\u957f\u5ea6\u4e0d\u4f1a\u8d85\u8fc7100)\u3002<\/p><h4 class=\"wp-block-heading\" id=\"header-id-2\" style=\"white-space: normal; box-sizing: border-box; margin-top: 3rem; margin-bottom: 15px; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif; font-weight: 600; line-height: 1.5; color: rgb(50, 50, 93); font-size: 18px;\">\u8f93\u51fa\u683c\u5f0f(Format Output)<\/h4><p style=\"font-size: 16px; white-space: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem; line-height: 1.8; overflow-wrap: break-word; caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\">\u4e00\u884c\uff0c\u5305\u542bN\u4e2a\u7528\u7a7a\u683c\u5206\u9694\u7684\u6574\u6570\uff0c\u5176\u4e2d\u7b2ci\u4e2a\u6574\u6570\u8868\u793a\u4ece\u70b9S\u51fa\u53d1\u5230\u70b9i\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6\uff08\u82e5S=i\u5219\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u4e3a0\uff0c\u82e5\u4ece\u70b9S\u65e0\u6cd5\u5230\u8fbe\u70b9i\uff0c\u5219\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u4e3a-1\uff09<\/p><hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"font-size: 16px; white-space: normal; box-sizing: content-box; overflow: visible; height: 0px; margin-top: 2rem; margin-bottom: 2rem; border-width: 0.0625rem 0px 0px; border-color: rgba(0, 0, 0, 0.1) currentcolor currentcolor; border-image-source: none; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\"><\/hr><h4 class=\"wp-block-heading\" id=\"header-id-3\" style=\"white-space: normal; box-sizing: border-box; margin-top: 3rem; margin-bottom: 15px; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif; font-weight: 600; line-height: 1.5; color: rgb(50, 50, 93); font-size: 18px;\">\u8f93\u5165\u6837\u4f8b(Sample Input)\u00a0<\/h4><p style=\"font-size: 16px; white-space: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem; line-height: 1.8; overflow-wrap: break-word; caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\">4 6 1 1 2 2 2 3 2 2 4 1 1 3 5 3 4 3 1 4 4<\/p><h4 class=\"wp-block-heading\" id=\"header-id-4\" style=\"white-space: normal; box-sizing: border-box; margin-top: 3rem; margin-bottom: 15px; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif; font-weight: 600; line-height: 1.5; color: rgb(50, 50, 93); font-size: 18px;\">\u8f93\u51fa\u6837\u4f8b(Sample Output)<\/h4><p style=\"font-size: 16px; white-space: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem; line-height: 1.8; overflow-wrap: break-word; caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\">0 2 4 3<\/p><hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"font-size: 16px; white-space: normal; box-sizing: content-box; overflow: visible; height: 0px; margin-top: 2rem; margin-bottom: 2rem; border-width: 0.0625rem 0px 0px; border-color: rgba(0, 0, 0, 0.1) currentcolor currentcolor; border-image-source: none; font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\"><\/hr><p style=\"font-size: 16px; white-space: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 1rem; line-height: 1.8; overflow-wrap: break-word; caret-color: rgb(82, 95, 127); color: rgb(82, 95, 127); font-family: echo, Georgia, -apple-system, &quot;Nimbus Roman No9 L&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Noto Serif SC&quot;, &quot;Microsoft Yahei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;ST Heiti&quot;, sans-serif;\"><strong style=\"box-sizing: border-box;\">\u4ee3\u7801(Code)<\/strong><\/p><pre class=\"wp-block-code\" style=\"font-family: Consolas, Menlo, Monaco, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 14px; overflow: auto; margin-top: 0px; margin-bottom: 1rem; color: rgb(94, 102, 135); line-height: 1.375; word-break: normal; tab-size: 4; hyphens: none; background: rgb(245, 247, 255); direction: ltr; border: 1px solid rgba(0, 0, 0, 0.12); padding: 14px; border-radius: 3px;\"><code style=\"box-sizing: border-box; font-family: Consolas, Menlo, Monaco, &quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, &quot;Nimbus Mono L&quot;, &quot;Courier New&quot;, Courier, monospace; word-break: normal; color: rgb(245, 54, 92); border-radius: 3px;\">#include&lt;bits\/stdc++.h><br>using namespace std;<br>struct point{<br>    int e,w;<br>}; <br>vector&lt;point>head[10010];<br>int n,m,s,dis[10010],used[10010];<br>int main()<br>{<br>    cin>>n>>m>>s;<br>    for(int i=1;i&lt;=m;i++)<br>    {<br>        int x,y,z;<br>        cin>>x>>y>>z;<br>        head[x].push_back(point{y,z});<br>    }<br>    memset(dis,0x7f,sizeof(dis));<br>    dis[s]=0;<br>    for(int i=1;i&lt;=n;i++)<br>    {<br>        int Min=1e9,k=0;<br>        for(int j=1;j&lt;=n;j++)<br>        {<br>            if(Min>dis[j]&amp;&amp;used[j]==0)<br>            {<br>                Min=dis[j],k=j;<br>            }<br>        }<br>        if(Min==1e9)\tbreak;<br>        used[k]=1;<br>        for(int j=0;j&lt;head[k].size();j++)<br>        {<br>            int v=head[k][j].e;<br>            int va=head[k][j].w;<br>            if(dis[v]>dis[k]+va)\tdis[v]=dis[k]+va;<br>        }<br>    }<br>    for(int i=1;i&lt;=n;i++)<br>    {<br>        if(dis[i]==0x7f7f7f7f)<br>        {<br>            cout&lt;&lt;-1&lt;&lt;\" \";<br>        }<br>        else<br>        {<br>            cout&lt;&lt;dis[i]&lt;&lt;\" \";<br>         } <br>    }<br>    return 0;<br>}<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u51fa\u4e00\u4e2a\u6709\u5411\u56fe\uff0c\u8bf7\u8f93\u51fa\u4ece\u67d0\u4e00\u70b9\u51fa\u53d1\u5230\u6240\u6709\u70b9\u7684\u6700\u77ed\u8def\u5f84\u957f\u5ea6\u3002 \u8f93\u5165\u683c\u5f0f(Format Input) \u7b2c\u4e00\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570N\u3001M\u3001S\uff0c\u5206\u522b\u8868\u793a\u70b9\u7684\u4e2a\u6570\u3001\u6709\u5411\u8fb9\u7684\u4e2a\u6570\u3001\u51fa\u53d1\u70b9\u7684\u7f16\u53f7\u3002 \u63a5\u4e0b\u6765M\u884c\u6bcf\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570Fi\u3001Gi\u3001Wi &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,1],"tags":[],"class_list":["post-279","post","type-post","status-publish","format-standard","hentry","category-js","category-origin"],"_links":{"self":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279"}],"version-history":[{"count":0,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=\/wp\/v2\/posts\/279\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.n-bc.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}