摘要:
题目大意:给你n个点,n-1条边,将图连成一棵生成树,问你从任意点为起点,走k(k=r+1,ans = r+(k-(r+1))*2;#include#include#includeusing namespace std;#define inf 999999999#define N 110000st... 阅读全文
摘要:
第一道自己做出来的区间dp题,兴奋ing,虽然说这题并不难。从后向前考虑:状态转移方程:dp[i][j]=dp[i+1][j](i#include#define N 300int dp[N][N];int a[N];int Ma(int a,int b){return a>b?a:b;}int ma... 阅读全文
摘要:
读懂题意就简单了#include#define inf 999999999#define N 310int f[N];int map[N][N];int main() { int n,m,i,j,k,a,b,max,ans; while(scanf("%d%d",&n,&m)!=EOF)... 阅读全文
摘要:
#include#include#define N 1100struct node {int u,v,w;}bian[110000];int pre[N];int cmp(const void *a,const void *b) {return (*(struct node *)b).w-(*(st... 阅读全文