"Problem Analysis"
First of all, according to the example given in the topic think as long as the price of each item to be able to synthesize his two items to update, while reading into one side of the update is good, and later found that if this happens: 1 2 3 in front of 2 5 6, Then we need to update 2 in Update 1 first. Yes, that's it. I used DFS and then the perfect stack of 75 points, of course, before that, I thought about it. If an item can be updated by more than one item, then we are using the side table to record down, find each group, but did not realize (side table child is also 75hh), Nancheng even built a tree. But the AC classmate is doing this, read in the time to update again, read it and then come back to update again .... Why!!! (Data water)
#include <cstdio>#include<cstring>#include<iostream>using namespacestd;#definell Long LongConst intmaxn=20010;intN,m;ll C[MAXN];intA[MAXN],X[MAXN],Y[MAXN];intPos;intf[maxn][5];ll Ans;ll Search (intAaintXxintyy) { if(xx==0&&yy==0) returnC[AA]; returnMin (C[aa],search (xx,f[xx][1],f[xx][2]) +search (yy,f[yy][1],f[yy][2]));}intMain () {Freopen ("dwarf.in","R", stdin); Freopen ("Dwarf.out","W", stdout); scanf ("%d%d",&n,&m); for(intI=1; i<=n;i++) scanf ("%d",&C[i]); for(intI=1; i<=m;i++) { intA,x,y; scanf ("%d%d%d",&a,&x,&y); f[a][1]=x;f[a][2]=y; } cout<<search (1, f[1][1],f[1][2]); Fclose (stdin); fclose (stdout); return 0;}
No AC
Red character Bad rating series 2.dwarf