Eto's open T3 "Searching for Stars" (by super-level/test field WA Monsters)

Source: Internet
Author: User

Finding a Star

Test instructions: Given a weighted graph, a path defined from one point to another is long as the maximum of all edge weights on the path and is given a four-point numberW,T1,T2,T3.

Find out a pointSand make it in toT1,t2 < Span class= "Mord" >,t3 three point shortest path maximum maximum or no path at all based on w Shortest path minimum.

Originally is to strengthen the data card Floyd, but also too late, Floyd no brain run again enumerate can. Note that this is a forward graph, and three of people are also considered human beings.

#include <cstdio>#include<algorithm>#include<cstring>using namespacestd;#defineINF 0x3f3f3f3f#defineFP (i,a,b) for (int i=a;i<=b;++i)intdis[ the][ the],n,m,w,t1,t2,t3,ans=-1, maxc=-1, minc=0x7fffffff;intMain () {scanf ("%d%d",&n,&m); memset (DIS,0x3f,sizeof(DIS)); FP (i,1, N) dis[i][i]=0; FP (i,1, M) {        intX,y,c; scanf ("%d%d%d",&x,&y,&c); Dis[x][y]=C; } fp (k,1, N) FP (i,1, N) FP (J,1, N)if(dis[i][j]>Max (Dis[i][k],dis[k][j]) dis[i][j]=Max (dis[i][k],dis[k][j]); scanf ("%d%d%d%d",&w,&t1,&t2,&T3); FP (i,1, N) {        if(i==w| | i==t1| | i==t2| | i==t3| | Dis[w][i]>=inf)Continue; intdt=min (dis[t1][i],min (dis[t2][i],dis[t3][i)); if(dt>MAXC) {MAXC=DT; Ans=i; }        Else if(dt==MAXC) {            if(dis[w][i]<minc) {Minc=Dis[w][i]; Ans=i; }}} printf ("%d", ans); return 0;}

Eto's open T3 "Searching for Stars" (by super-level/test field WA Monsters)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.