Statement: The subject only 80 points, for the provision of ideas. Description in a faraway world there are two countries: Jason, located at the western end of the continent and the Chris State on the eastern tip of the continent. The peoples of two countries believe in two opposing gods: Jason's faith symbolizes the Zeng Blaze of the dark and destructive gods, and the Christian faith symbolizes the light and eternal Shenspring Blaze.
Fantasy Calendar in January 8012, Jason State formally declared that Zeng Blaze was the only god they believed in, and began to persecute the Christian Spring Blaze of the faith in Jason State.
On March 2, 8012, the Christian church in the town of the eastern town of Jason was launched into an uprising.
Fantasy Calendar March 7, 8012, the town of Oracle Uprising by the army of Jason the brutal means of repression.
March 8, 8012, Chris State declares war on Jason State. The hundreds of thousands of-Army Chris Regiment opened to the border of the two countries and confronted Jason's regiment.
In April 8012, the Chris Legion breached Jason's regiment into the Oracle town, where the surviving Christian Christians were liberated.
The war then entered a stalemate, protracted. The war is tragic, a time of gunfire, smoke, hardship.
Fantasy Calendar The night of May 12, 8012, Spring Blaze lowered the Oracle: "Trust me, Earn eternal life." The morale of the Chris Legion has increased greatly. As the manager of the Chris Legion, you decided to take this opportunity to launch a surprise attack and defeat Jason in one swoop. Specifically, Jason is a state-owned N-city, connected by M-one-way roads. Oracle town is the city of 1 and Jason is the capital city of N. All you need to do is destroy the Zeng Blaze Grand Shrine, which is located in the capital of Jason, and the faith of Jason, the army and everything will fall apart and vanish.
In order to minimize your own consumption, you decide to use a self-destruct robot to accomplish this task. The only difficulty is that some of Jason's cities have a boundary protection and cannot enter the city without destroying the boundary. The boundaries of each city are maintained by some of the junction generators that are distributed in other cities, and if you want to enter a city, you must destroy all the junction generators that sustain the city's boundary.
Now that you have an infinite number of self-destruct robots, once in a city, a self-destruct robot can detonate instantaneously, destroying a target (the junction generator, or Jason's grand shrine), and of course the robot itself will be destroyed. You need to know: the shortest time required to destroy Jason's country. Input format the first line two positive integers n, M.
Next m line, three positive integers per line UI, VI, WI, represents a one-way road from the city UI to City VI, and the self-destruct robot takes WI time through this road.
After n rows, each row describes a city. The first is a positive integer li, which maintains the number of junction generators used in the urban boundary. Then the city number between Li 1~n indicates the location of each junction generator. If Li = 0, it means that the city does not have a boundary protection and is guaranteed L1 = 0. The output format contains only a positive integer, and the shortest time required to defeat Jason State. Test Sample 1 input
6 6
1 2 1
1 4 3
2 3 1
2 5 2
4 6 2
5 3 2
0
0
0
1 3
0
2 3 5
Output
5
Note for 20% of data, to meet n≤15,m≤50;
For 50% of data, meet n≤500,m≤6,000;
For 100% of data, meet n≤3,000,m≤70,000,1≤wi≤108.
The input data is guaranteed to have a solution, and there is no boundary generator to maintain a city boundary within the city.
There may be more than one road connecting two cities, and there may be a city itself to its own path. Dijkstra the shortest circuit with a limit. For protected points to be marked, each time you enter the team, the least protected distance of the point K is added to the graph, first update all the points, and then the point K protected Point distance to update (max (Dis[k],dis[j]) and Mark-1). It is better to use arrays to simulate linked lists, although smaller matrices are also available.
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib>using namespace std; int N,m,x,y,z,k,mind,num,map[3001][3001],dis[3001],pro[3001][3001],pr[3001];bool v[3001]; int main () {scanf ("%d%d", &n,&m); for (int i=0;i<=n;i++) for (int j=0;j<=n;j++) map[i][j]=1000000007; for (int i=1;i<=m;i++) {scanf ("%d%d%d", &x,&y,&z); Map[x][y]=z; } memset (Pro,0,sizeof (pro)); memset (pr,0,sizeof (PR)); for (int i=1;i<=n;i++) {scanf ("%d", &pr[i]); if (pr[i]==0) continue; for (int j=1;j<=pr[i];j++) {scanf ("%d", &x); Pro[x][i]=true; }} for (int i=0;i<=n;i++) dis[i]=100000007; dis[1]=0; memset (v,0,sizeof (v)); for (int i=1;i<n;i++) {k=0; for (int j=1;j<=n;j++) if (!pr[j]&&!v[j]&&dis[j]<dis[k]) k=j; if (k==n) break; V[k]=true; For (int j=1;j<=n;j++) if (Dis[k]+map[k][j]<dis[j]) dis[j]=dis[k]+map[k][j]; for (int j=1;j<=n;j++) if (Pro[k][j]) {pr[j]--; Dis[j]=max (Dis[j],dis[k]); }} printf ("%d", dis[n]); return 0;}
#0: wrong Answer (0ms, 71284KiB)
Line 1th does not match the answer output
Answer output:
927
Player output:
1738
#1: Accepted (0ms, 71288KiB)
#2: Accepted (0ms, 71280KiB)
#3: Accepted (15ms, 71284KiB)
#4: Accepted (0ms, 71284KiB)
#5: wrong Answer (62ms, 71284KiB)
Line 1th does not match the answer output
Answer output:
4844
Player output:
4910
#6: Accepted (93ms, 71280KiB)
#7: Accepted (78ms, 71280KiB)
#8: Accepted (93ms, 71284KiB)
#9: Accepted (93ms, 71280KiB)
Only 80 ', do not know where there is a problem, look at the way the great God advice.
[SDOI2010] [TYVJ P1736] Continental hegemony [80]