Title: http://www.lydsy.com/JudgeOnline/problem.php?id=1006
The problem is: this should be the longest stay of a hole ... Today finally a dropped ... But there is still no sense of total understanding.
Code:
1#include <cstdio>2#include <cstdlib>3#include <cmath>4#include <cstring>5#include <algorithm>6#include <iostream>7#include <vector>8#include <map>9#include <Set>Ten#include <queue> One#include <string> A#include <bitset> - #defineINF 1000000000 - #defineMAXN 2000000+5 the #defineMAXM 10000000 - #defineEPS 1e-10 - #definell Long Long - #definePA pair<int,int> + #defineFor0 (i,n) for (int i=0;i<= (n); i++) - #defineFor1 (i,n) for (int i=1;i<= (n); i++) + #defineFor2 (i,x,y) for (int i= (x); i<= (y); i++) A #defineFor3 (i,x,y) for (int i= (x); i>= (y); i--) at #defineFor4 (i,x) for (int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go) - #defineMoD 1000000007 - #defineLCH K<<1,l,mid - #defineRCH K<<1|1,mid+1,r - using namespacestd; -InlineintRead () in { - intx=0, f=1;CharCh=GetChar (); to while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} + while(ch>='0'&&ch<='9') {x=Ten*x+ch-'0'; ch=GetChar ();} - returnx*F; the } * intN,M,TOT,HEAD[MAXN],ID[MAXN],POS[MAXN],V[MAXN]; $Priority_queue<pa>Q;Panax Notoginseng structedge{intGo,next;} E[MAXN]; -InlinevoidAddintXinty) the { +E[++tot]= (Edge) {y,head[x]};head[x]=tot; AE[++tot]= (Edge) {x,head[y]};head[y]=tot; the } + intMain () - { $Freopen ("Input.txt","R", stdin); $Freopen ("output.txt","W", stdout); -N=read (); m=read (); - For1 (i,m) Add (read (), read ()); theFor1 (I,n) Q.push (PA (0, i)); -For3 (I,n,1)Wuyi { the while(Id[q.top (). Second]) Q.pop (); - intx=q.top (). Second;q.pop (); WuFor4 (j,x)if(!id[y]) Q.push (PA (+ +)v[y],y)); -id[x]=i;pos[i]=x; About } $ intans=1; - For1 (i,n) - { - inttmp=0; AFor4 (J,i)if(Id[y]>id[i]) tmp++; +Ans=max (ans,tmp+1); the } -cout<<ans<<Endl; $ return 0; the}
View Code
BZOJ1006: [HNOI2008] The Magical kingdom