当前位置: 首页 > news >正文

网站推广方式措施hao123网址导航

网站推广方式措施,hao123网址导航,阿里云服务器做网站好用吗,邢台网站建设哪里有Problem - E - Codeforces 思路:我们考虑用树形dp,用f[i][0]表示以i为根,并且当前节点不在最长上升子序列中,用f[i][1]表示以i为根,当前节点在最长上升子序列中,那么f[i][0]max(f[j][0],f[j][1])&#xff0…

Problem - E - Codeforces

思路:我们考虑用树形dp,用f[i][0]表示以i为根,并且当前节点不在最长上升子序列中,用f[i][1]表示以i为根,当前节点在最长上升子序列中,那么f[i][0]+=max(f[j][0],f[j][1]),因为对于以i为根的子树来说,i的所有子节点组成的子树是没有关联的,所以不包含当前节点的最长上升子序列就是每个子节点的最长上升子序列的和,f[i][1]=max(f[i][1],f[j][1]+1),如果包含当前节点,因为我一定是在删除了所有的子节点之后才删除当前节点,所以我这个节点的值一定是子节点中除1之外的最小的值,并且它只有其中的某一个子节点能够等于这个值,那么我们为了让它最大,肯定是挑路径最长的那个子节点的值等于这个值,这样就能够让f[i][1]最大,所以f[i][1]只需要找以i为根的最长的路径就可以

// Problem: E. Hanging Hearts
// Contest: Codeforces - Codeforces Round 831 (Div. 1 + Div. 2)
// URL: https://codeforces.com/problemset/problem/1740/E
// Memory Limit: 256 MB
// Time Limit: 1000 ms#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
#include<bitset>
#include<deque>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<queue>
#include<map>
#include<stack>
#include<vector> 
#include<set>
#include<cstdlib>
#define fi first
#define se second
#define i128 __int128
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef pair<int,pair<int,int> > PIII;
const double eps=1e-7;
const int N=5e5+7 ,M=5e5+7, INF=0x3f3f3f3f,mod=1e9+7,mod1=998244353;
const long long int llINF=0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x=0,f=1;char c=getchar();while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(ll)x*10+c-'0';c=getchar();} return x*f;}
inline void write(ll x) {if(x < 0) {putchar('-'); x = -x;}if(x >= 10) write(x / 10);putchar(x % 10 + '0');}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen("in_put.txt","r",stdin);freopen("my_out_put.txt","w",stdout);}
bool cmp0(int a,int b) {return a>b;}
template<typename T> T gcd(T a,T b) {return b==0?a:gcd(b,a%b);}
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf("\n----------------------------------\n");}int T,hackT;
int n,m,k;
vector<int> h[N];
int f[N][2];void dfs(int u,int fa) {f[u][1]=1;for(int i=0;i<h[u].size();i++) {int j=h[u][i];if(j==fa) continue;dfs(j,u);f[u][0]+=max(f[j][0],f[j][1]);f[u][1]=max(f[u][1],f[j][1]+1);}
}void solve() {n=read();for(int i=2;i<=n;i++) {int c=read();h[c].push_back(i);h[i].push_back(c);}dfs(1,-1);printf("%d\n",max(f[1][0],f[1][1]));
}   int main() {// init();// stin();//ios::sync_with_stdio(false); // scanf("%d",&T);T=1; while(T--) hackT++,solve();return 0;       
}          

http://www.shuangfujiaoyu.com/news/19213.html

相关文章:

  • 专业网站建设推广sem管理工具
  • 网站设计 卡片式设计长沙百家号seo
  • 诚信网站体系建设工作总结如何建立网站服务器
  • wordpress编辑文章更新失败班级优化大师的利和弊
  • 湖南省郴州市嘉禾县网站seo批量查询工具
  • 懒人模板网站网络推广app是违法的吗
  • 宝鸡门户网站开发下载互联网营销渠道有哪些
  • 凡科建站源码深圳开发公司网站建设
  • 重庆网站制作外包公司南宁做网站公司
  • 网站建设 徐州策划营销推广方案
  • 一站式做网站技术简述什么是百度竞价排名
  • 做平面素材比较好的网站媒体发稿平台
  • 中企动力做网站多久能好seo 培训教程
  • 婚纱动态网站模板谷歌seo建站
  • 云集网站哪个公司做的google adsense
  • 毕业设计网站设计说明书高质量网站外链平台
  • 宣传片拍摄手法有哪些seo初级入门教程
  • 崇明做网站网站竞价推广托管公司
  • 网站建设副业搜索网站排行
  • 专业做网站的网络策划营销
  • 做公司网站需要会什么长春seo排名扣费
  • 千锋教育怎么样seo排名查询工具
  • 江津做网站百度竞价入口
  • 广州设计公司网站石家庄百度关键词搜索
  • 湖北立方建设工程有限公司网站网站建设的流程是什么
  • 深圳微信分销网站制作西安百度seo推广
  • 网站开发管理企业推广策略
  • 接广告的网站十大引擎网址
  • 网页设计师培训费用预算图上海牛巨微seo
  • 如何去推广一个网站网站需要怎么优化比较好