Red character Bad rating series 2.dwarf

Source: Internet
Author: User

"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

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.