{"id":2997,"date":"2023-06-08T02:04:52","date_gmt":"2023-06-07T18:04:52","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2997"},"modified":"2023-06-08T02:04:52","modified_gmt":"2023-06-07T18:04:52","slug":"luogu-p2046-noi2010-%e6%b5%b7%e6%8b%94","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/luogu-p2046-noi2010-%e6%b5%b7%e6%8b%94\/","title":{"rendered":"Luogu P2046. [NOI2010] \u6d77\u62d4"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/www.luogu.com.cn\/problem\/P2046\">https:\/\/www.luogu.com.cn\/problem\/P2046<\/a><\/li>\n<\/ul>\n<p>\u7b80\u5355\u7684\u5e73\u9762\u56fe\u6700\u5c0f\u5272\uff0c\u96be\u70b9\u662f\u8bc1\u8fd9\u4e2a\u662f\u6700\u5c0f\u5272\u3002<br \/>\n\u4ee3\u7801\u4e3b\u6253\u7684\u662f\u4e00\u624b\u5bf9\u79f0\u3002= =<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include &lt;lastweapon\/io&gt;\r\n#include &lt;lastweapon\/dijkstra&gt;\r\n\r\nusing namespace lastweapon;\r\n\r\nint n, s, t;\r\n\r\nint id(int x, int y) {\r\n    if (x == -1 || y == n) return s;\r\n    if (x == n || y == -1) return t;\r\n    return x*n + y;\r\n}\r\n\r\nint main() {\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;\/Users\/minakokojima\/Documents\/GitHub\/ACM-Training\/Workspace\/out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    RD(n); s=n*n; t=s+1; sp_graph&lt;int&gt; G(t+1);\r\n\r\n    REP(x, n+1) REP(y, n) G.add_edge(id(x-1,y), id(x,y), RD());\r\n    REP(x, n) REP(y, n+1) G.add_edge(id(x,y), id(x,y-1), RD());\r\n    REP(x, n+1) REP(y, n) G.add_edge(id(x,y), id(x-1,y), RD());\r\n    REP(x, n) REP(y, n+1) G.add_edge(id(x,y-1), id(x,y), RD());\r\n\r\n    cout &lt;&lt; G.dijkstra(s, t) &lt;&lt; endl;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.luogu.com.cn\/problem\/P2046 \u7b80\u5355\u7684\u5e73\u9762\u56fe\u6700\u5c0f\u5272\uff0c\u96be\u70b9\u662f\u8bc1\u8fd9\u4e2a\u662f\u6700\u5c0f\u5272\u3002 \u4ee3\u7801\u4e3b\u6253\u7684\u662f\u4e00\u624b\u5bf9\u79f0\u3002= = #include &lt;lastweapon\/io&gt; #include &lt;lastweapon\/dijkstra&gt; using namespace lastweapon; int n, s, t; int id(int x, int y) { if (x == -1 || y == n) return s; if (x == n || y == -1) return t; return x*n + y; } int main() { #ifndef ONLINE_JUDGE freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin); \/\/freopen(&quot;\/Users\/minakokojima\/Documents\/GitHub\/ACM-Training\/Workspace\/out.txt&quot;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-2997","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-Ml","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=2997"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2997\/revisions"}],"predecessor-version":[{"id":2998,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2997\/revisions\/2998"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}