BZOJ2535: [Noi2010]plane Aviation Control 2

Source: Internet
Author: User

Title: http://www.lydsy.com/JudgeOnline/problem.php?id=2535

Reverse the diagram, sort the topology, use and check set to maintain the current weight can be placed in the largest position. For the second question, it is equivalent to I ban the point I cut off and then go to find the last!ans[i] position. Then the first question is which point is not ban.

#include <cstring>#include<cctype>#include<cstdio>#include<algorithm>#include<cmath>#include<queue>#defineRep (i,l,r) for (int i=l;i<=r;i++)#defineDown (i,l,r) for (int i=l;i>=r;i--)#defineCLR (x, y) memset (x,y,sizeof (×))#definell Long Long#defineMAXN 2005#defineMM Int (1e9+7)using namespacestd;structedge{intObj,pre;} e[200500];intANS[MAXN],MN[MAXN],D[MAXN],T[MAXN],HEAD[MAXN],DD[MAXN],FA[MAXN],Q[MAXN];intN,m,x,y,tot,cnt,ban;voidInsertintXinty) {e[++tot].obj=y; E[TOT].PRE=HEAD[X]; head[x]=tot;}intRead () {intx=0, f=1;CharCh=GetChar ();  while(!isdigit (CH)) {if(ch=='-') f=-1; Ch=GetChar ();}  while(IsDigit (CH)) {x=x*Ten+ch-'0'; Ch=GetChar ();} returnx*F;}int Get(intx) {    if(fa[x]==x)returnx; returnfa[x]=Get(Fa[x]);}voiddpintban) {Rep (i,1, N) d[i]=dd[i],fa[i]=i,ans[i]=0, Mn[i]=min (N,t[i]); Cnt=0; Rep (I,1, N)if(!d[i]) q[++cnt]=i;  while(CNT) {intu=q[cnt--]; if(U==ban)Continue; intpos=Get(Mn[u]); Ans[pos]=u; fa[pos]=pos-1;  for(intj=head[u];j;j=e[j].pre) {            intV=e[j].obj; d[v]--; MN[V]=min (mn[v],mn[u]); if(!d[v]) q[++cnt]=v; }    }}intMain () {n=read (); m=read (); Rep (I,1, N) t[i]=read (); Rep (I,1, M) {x=read (); y=read ();           Insert (Y,X); DD[X]++; } DP (0); Rep (I,1, N-1) printf ("%d", Ans[i]); printf"%d\n", Ans[n]); Rep (I,1, N)           {DP (i); Down (J,n,1)if(!Ans[j]) {printf ("%d%c", J,i==n?'\ n':' ');  Break; }       }    return 0; }

BZOJ2535: [Noi2010]plane Aviation Control 2

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.