1927: [Sdoi2010] Star Racing

Source: Internet
Author: User

1927: [Sdoi2010] Star Racing time limit:20 Sec Memory limit:259 MB
submit:2040 solved:1257
[Submit] [Status] [Discuss] Description

The 10 Galaxy racing race begins again. As one of the biggest events in the Galaxy, the winner of this project is undoubtedly a lot of people's
Dream, the one from Jason's Alpha star. The race is made up of n planets and M two-way interstellar routes, each of which
There is a different gravitational value. The competition requires drivers to access the N planets from a celestial body that has no route between the N planets, each of which happens
Once, the first person to accomplish this goal wins. Because the format is very open, many people are driving strange, homemade cars to compete. This time leisurely
The driving car is called the Super Power Donkey, which is a dream car that condenses the most cutting-edge technology in the galaxy. As the most high-tech product, Super Electric donkey has
Two modes of movement: high-speed sailing mode and ability burst mode. In high-speed mode, an ultra-electric donkey will launch an antimatter engine, which can be multiplied by the speed of light
Speed sailing along the interplanetary route. In the ability to burst mode, the Super Electric donkey out of time and space, the use of super-ability to jump--after a
After the positioning of the time, it can move instantaneously to any planet. Days days wondering people wish, the day before the game, Super Electric Donkey in an ion storm not
Fortunately, the function has some obstacles: when using the high-speed navigation mode, only each planet can fly to the larger gravity than the planet, otherwise the car will
An explosion will occur. Despite the problems of the beloved car, he still believes that he can win. He found the smartest sage in the whole galaxy--
You, please arrange a game plan for him, so that he can finish the game with the least amount of time.

Input

The first line is a two positive integer n,m. The second row n number A1~an, where AI represents the location time required to reach planet I using the ability burst mode. Pick up the
To M-line, 3 positive integers per line, ui,vi,wi the existence of an interstellar route between planets numbered UI and VI that require sailing WI time. Input data
have been sorted by gravitational value, that is, the small number of planets gravitational value must be small, and no two planets have the same gravitational value.

Output

Contains only a positive integer that represents the minimum time required to complete the match.

Sample Input3 3
1 100 100
2 1 10
1 3 1
2 3 1Sample Output AHINT

Description: Use the ability to burst mode to Planet 1, which takes time 1. Then switch to high-speed sailing mode and sail to Planet 2, which takes time 10. Of

After continuing sailing to Planet 3 to complete the race, it took time 1. Although it looks better from Planet 1 to Planet 3 to Planet 2, we can't do that because

For that would cause the super electric donkey to explode. n≤800,m≤15000. No number in the input data will exceed 106. Enter data to guarantee any two planets

There is at most one fairway, and there is no planet to its own fairway.

Source

First round Day2

From Wmy's puzzle: Split//Don't understand why the split S is connected to every right-hand point, the cost is the location cost, the capacity is 1, with each left point between the edge, the cost is 0, is split between the edge, the cost is 0, the capacity is 1, the left point can be reached to the right point, the capacity is 1, the cost is the length of the distance, Each right-hand point is connected to the T with a charge of 0 and a flow of 1.
#include <cstdio>#include<cstring>#include<iostream>#defineM (s,t) memset (s,t,sizeof s)#defineR Register#defineINF 2139062143using namespacestd;Const intn=2510;Const intm=3e6+Ten;structnode{intV,next,cap,cost;} E[M];inttot=1;intn,m,s,t,ans,head[n],pree[n],prev[n],flow[n],dis[n],q[n*Ten];BOOLVis[n];voidAddintXintYintAintb) {e[++tot].v=y;e[tot].cap=a;e[tot].cost=b;e[tot].next=head[x];head[x]=tot;}voidInsintXintYintAintb) {Add (x,y,a,b); Add (Y,x,0,-b);}voidCl () {tot=1; ans=0; M (Head,0); M (Pree,0); M (prev,0); m (Flow,0);}BOOLSPFA () {m (Vis,0); M (Dis,127); intH=0, t=1; Q[t]=s;dis[s]=0; vis[s]=1; flow[s]=inf;  while(h!=t) {        intx=q[++h]; VIS[X]=0;  for(intI=head[x];i;i=E[i].next) {            intv=e[i].v,cap=e[i].cap,cost=E[i].cost; if(cap>0&&dis[v]>dis[x]+Cost ) {Dis[v]=dis[x]+Cost ; PREV[V]=x;pree[v]=i; FLOW[V]=min (flow[x],cap); if(!Vis[v]) {Vis[v]=1; q[++t]=v; }            }        }    }    returndis[t]<inf;}voidWork () { for(intI=t;i!=s;i=Prev[i]) {E[pree[i]].cap-=Flow[t]; E[pree[i]^1].cap+=Flow[t]; } ans+=flow[t]*dis[t];}intMain () {scanf ("%d%d", &n,&m); s=0, t=n*2+1;  for(intI=1, w;i<=n;i++) {scanf ("%d",&W); INS (0I1,0); INS (0, I+n,1, W); INS (i+n,t,1,0); }     for(intI=1, u,v,w;i<=m;i++) {scanf ("%d%d%d",&u,&v,&W); if(u>v) swap (u,v); INS (u,v+n,1, W); }     while(SPFA ()) work (); printf ("%d", ans); return 0;}

1927: [Sdoi2010] Star Racing

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.