{"id":83,"date":"2012-09-21T17:52:00","date_gmt":"2012-09-21T09:52:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/83"},"modified":"2012-09-21T17:52:00","modified_gmt":"2012-09-21T09:52:00","slug":"poj_2110_minimum_spanning_tree","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=83","title":{"rendered":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09"},"content":{"rendered":"<p>\u8fd9\u9898\u7684\u601d\u8def\u5c31\u662f\u627e\u4e00\u4e2a\u8303\u56f4\uff0c\u770b\u770b\u8fd9\u4e2a\u8303\u56f4\u662f\u5426\u53ef\u884c<\/p>\n<p>\u4e3b\u6d41\u662f\u4e8c\u5206Ans\uff0c\u6211\u662f\u5148\u628a\u70b9\u6392\u5e8f\uff0c\u6c42\u6700\u5c0f\u751f\u6210\u6811\u68c0\u67e5\u9996\u4f4d\u7684<\/p>\n<p>\n<\/p>\n<p><pre name=\"code\" class=\"delphi\">Program P2110;\ntype\n   ed=record\n      u,v,w:longint;\n      end;\nvar\n   a:array[1..120,1..120] of longint;\n   edge:array[0..30000] of ed;\n   n,i,j,size,ans:longint;\n   now:longint;\n   father:array[0..10001] of longint;\n   b:array[0..121,0..121] of boolean;\nprocedure add(u,v,w:longint);\nbegin\n   inc(size);\n   edge[size].u:=u;\n   edge[size].v:=v;\n   edge[size].w:=w;\n\nend;\nprocedure qsort(l,r:longint);\nvar\n   i,j,m:longint;\n   p:ed;\nbegin\n   i:=l;\n   j:=r;\n   m:=edge[(l+r) shr 1].w;\n   repeat\n      while edge[i].w&lt;m do inc(i);\n      while edge[j].w&gt;m do dec(j);\n      if i&lt;=j then\n      begin\n         p:=edge[i];\n         edge[i]:=edge[j];\n         edge[j]:=p;\n         inc(i);\n         dec(j);\n      end;\n   until i&gt;j;\n   if l&lt;j then qsort(l,j);\n   if i&lt;r then qsort(i,r);\n\n\n\nend;\nfunction getfather(x:longint):longint;\nbegin\n   if x=father[x] then exit(x);\n   father[x]:=getfather(father[x]);\n   exit(father[x]);\nend;\nfunction hash(x,y:longint):longint;\nbegin\n  exit((x-1)*n+y);\nend;\nbegin\n   size:=0;\n   read(n);\n   for i:=1 to n do\n      for j:=1 to n do\n      begin\n         read(a[i,j]);\n         add(i,j,a[i,j]);\n      end;\n\n  \/\/ (0,n*n)\n   qsort(1,size);\n\n\n   edge[0].w:=edge[1].w-1;\n   ans:=110;\n   \/\/                 writeln;\n   for i:=1 to size do\n   begin\n\n      if edge[i].w=edge[i-1].w then continue;\n      for j:=0 to n*n do father[j]:=j;\n      fillchar(b,sizeof(b),false);\n      for j:=i to size do\n      begin\n         b[edge[j].u,edge[j].v]:=true;\n         now:=hash(edge[j].u,edge[j].v);\n\n         if b[edge[j].u-1,edge[j].v] then\n            if getfather(now)&lt;&gt;getfather(now-n) then\n            begin\n               father[father[now]]:=father[father[now-n]];\n               if getfather(0)=getfather(n*n) then break;\n            end;\n\n         if b[edge[j].u+1,edge[j].v] then\n            if getfather(now)&lt;&gt;getfather(now+n) then\n            begin\n               father[father[now]]:=father[father[now+n]];\n               if getfather(0)=getfather(n*n) then break;\n            end;\n\n         if b[edge[j].u,edge[j].v+1] then\n            if getfather(now)&lt;&gt;getfather(now+1) then\n            begin\n               father[father[now]]:=father[father[now+1]];\n               if getfather(0)=getfather(n*n) then break;\n            end;\n\n         if b[edge[j].u,edge[j].v-1] then\n            if getfather(now)&lt;&gt;getfather(now-1) then\n            begin\n               father[father[now]]:=father[father[now-1]];\n               if getfather(0)=getfather(n*n) then break;\n            end;\n\n\n\n         if getfather(1)=getfather(n*n) then break;\n\n      end;\n\n\n\n      if getfather(1)&lt;&gt;getfather(n*n) then break;\n      if ans&gt;edge[j].w-edge[i].w then ans:=edge[j].w-edge[i].w;\n\n\n   end;\n   writeln(ans);\n\n\n\nend.\n<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u9898\u7684\u601d\u8def\u5c31\u662f\u627e\u4e00\u4e2a\u8303\u56f4\uff0c\u770b\u770b\u8fd9\u4e2a\u8303\u56f4\u662f\u5426\u53ef\u884c \u4e3b\u6d41\u662f\u4e8c\u5206Ans\uff0c\u6211\u662f\u5148\u628a\u70b9\u6392\u5e8f\uff0c\u6c42\u6700\u5c0f\u751f\u6210\u6811\u68c0\u67e5\u9996\u4f4d\u7684 Pr [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[76],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-and_check_the_set"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nike0good.com\/?p=83\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u9898\u7684\u601d\u8def\u5c31\u662f\u627e\u4e00\u4e2a\u8303\u56f4\uff0c\u770b\u770b\u8fd9\u4e2a\u8303\u56f4\u662f\u5426\u53ef\u884c \u4e3b\u6d41\u662f\u4e8c\u5206Ans\uff0c\u6211\u662f\u5148\u628a\u70b9\u6392\u5e8f\uff0c\u6c42\u6700\u5c0f\u751f\u6210\u6811\u68c0\u67e5\u9996\u4f4d\u7684 Pr [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=83\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2012-09-21T09:52:00+00:00\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09\",\"datePublished\":\"2012-09-21T09:52:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83\"},\"wordCount\":2,\"commentCount\":0,\"keywords\":[\"\u5e76\u67e5\u96c6\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=83#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=83\",\"name\":\"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"datePublished\":\"2012-09-21T09:52:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=83\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=83#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nike0good.com\/?p=83","og_locale":"zh_CN","og_type":"article","og_title":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good","og_description":"\u8fd9\u9898\u7684\u601d\u8def\u5c31\u662f\u627e\u4e00\u4e2a\u8303\u56f4\uff0c\u770b\u770b\u8fd9\u4e2a\u8303\u56f4\u662f\u5426\u53ef\u884c \u4e3b\u6d41\u662f\u4e8c\u5206Ans\uff0c\u6211\u662f\u5148\u628a\u70b9\u6392\u5e8f\uff0c\u6c42\u6700\u5c0f\u751f\u6210\u6811\u68c0\u67e5\u9996\u4f4d\u7684 Pr [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=83","og_site_name":"nike0good","article_published_time":"2012-09-21T09:52:00+00:00","author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=83#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=83"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09","datePublished":"2012-09-21T09:52:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=83"},"wordCount":2,"commentCount":0,"keywords":["\u5e76\u67e5\u96c6"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=83#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=83","url":"https:\/\/nike0good.com\/?p=83","name":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09 - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"datePublished":"2012-09-21T09:52:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=83#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=83"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=83#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"POJ 2110(\u6700\u5c0f\u751f\u6210\u6811\uff09"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}