表示原来用RMQ和LCA做的方法烦了,现在直接在建最小生成树的过程中建双向边就好了, cost[i][j]表示i到j的最长树边View Code 1 #include<string.h> 2 #include<stdio.h> 3 #include<vector> 4 #include<math.h> 5 #include<queue> 6 using namespace std; 7 const int M =1010; 8 const double inf = 1e20; 9 double max(double a,double Read More
#include<string.h>#include<stdio.h>#include<math.h>const int MAX=200005;int min(int a,int b){return a<b?a:b;}int dp[MAX][20],a[MAX];int n,k,val[MAX];int LOG[MAX];void Make_Rmq(int n,int b[]){ int i,j; for(i=1;i<=n;i++) dp[0][i]=b[i]; for(i=1;i<=LOG[n];i++) { int limit=n+1- Read More