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

重庆网站制作套餐系统优化的意义

重庆网站制作套餐,系统优化的意义,一个网站怎么做新闻模块,重庆忠县网站建设题目 流量监控 - HDU 7401 - Virtual Judge 简单来说&#xff0c;T(T<20)组样例&#xff0c;sumn不超过2e4 每次给定一棵n(n<2000)个点的树&#xff0c;两问&#xff1a; ①将n个点恰拆成n/2个pair(u,v)&#xff0c;要求一个点是另一个点的祖先&#xff0c;求方案数 …

题目

流量监控 - HDU 7401 - Virtual Judge

简单来说,T(T<=20)组样例,sumn不超过2e4

每次给定一棵n(n<=2000)个点的树,两问:

①将n个点恰拆成n/2个pair(u,v),要求一个点是另一个点的祖先,求方案数

②若两个pair(u,v)、(w,x)满足:

u是v、w、x的祖先,w是v、x的祖先,v是x的祖先

即,四个点都在x通往根的路径上,且[u,v]和[w,x]相交,则称形成了一个区间交,

在①的所有合法方案数中,求区间交的总数

输出①、②的值,答案对998244353取模

思路来源

jiangly代码&heltion&tiger2005&夏老师

题解

 对着jiangly代码,找了若干人讨论,终于讨论明白了

第一问,dp[i][j]表示i子树内当前有j个未匹配的点的方案数,

转移是一个树上背包,对子树做完树上背包之后,

再考虑u这个点的决策,要么是(,要么是)

换句话说,要么选一个之前未匹配的点进行匹配,要么新增一个未匹配的点

第二问,长度为4的祖先链(都在通往祖先的一条路径上),所以可以考虑把0-4都维护上,

这里实际是考虑每个长度为4的链的贡献,

即在dp的时候并不指定这四个点连的方式,只统计四元组的总方案数,

然后根据题目要求, 最后的时候将13相连、24相连

这相当于求从树上抠掉四个点(四个点在一条祖先链上)时,剩下的点构成合法方案的方案数

f[i][j][k]表示考虑到j的子树,当前抠掉了i个点,还有k个点没有匹配的方案数

相当于一个二维背包,i是一维,k是一维

转移先对u的子树v1、v2、...做背包,做k这一维的背包,

又因为不同子树之间的点并不在一条祖先链上,

所以i这一维做背包两两合并的时候,两棵子树的i这一维不能同时大于0

        rep(a,0,4){rep(b,0,4){if(a && b)continue;rep(i,0,sz[u]){rep(j,0,sz[v]){add(tmp[a+b][i+j],1ll*f[a][u][i]*f[b][v][j]%mod);}}}}

将子树都合并进来之后,再考虑u的决策,

u的决策实际有三种, 要么是(,要么是),要么从树上抠掉

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define dbg(x) cerr<<(#x)<<":"<<x<<" ";
#define dbg2(x) cerr<<(#x)<<":"<<x<<endl;
#define SZ(a) (int)(a.size())
#define sci(a) scanf("%d",&(a))
#define pt(a) printf("%d",a);
#define pte(a) printf("%d\n",a)
#define ptlle(a) printf("%lld\n",a)
#define debug(...) fprintf(stderr, __VA_ARGS__)
const int N=2e3+10,mod=998244353,inv2=(mod+1)/2;
int T,n,u,v,sz[N],tmp[5][N],f[5][N][N];
vector<int>e[N];
void add(int &x,int y){x=(x+y)%mod;
}
void dfs(int u,int fa){sz[u]=1;f[0][u][0]=1;for(auto &v:e[u]){if(v==fa)continue;dfs(v,u);memset(tmp,0,sizeof tmp);rep(a,0,4){rep(b,0,4){if(a && b)continue;rep(i,0,sz[u]){rep(j,0,sz[v]){add(tmp[a+b][i+j],1ll*f[a][u][i]*f[b][v][j]%mod);}}}}sz[u]+=sz[v];rep(a,0,4){rep(i,0,sz[u]){f[a][u][i]=tmp[a][i];}}}memset(tmp,0,sizeof tmp);rep(a,0,4){rep(i,0,sz[u]){if(i)add(tmp[a][i-1],1ll*f[a][u][i]*i%mod);add(tmp[a][i+1],f[a][u][i]);if(a<4)add(tmp[a+1][i],f[a][u][i]);}}rep(a,0,4){rep(i,0,sz[u]){f[a][u][i]=tmp[a][i];}}
}
int main(){scanf("%d",&T);while(T--){sci(n);rep(i,1,n){e[i].clear();sz[i]=0;}memset(f,0,sizeof f);rep(i,2,n){sci(u),sci(v);e[u].pb(v);e[v].pb(u);}dfs(1,0);printf("%d %d\n",f[0][1][0],f[4][1][0]);}return 0;
}


文章转载自:
http://dinncoextortionary.tpps.cn
http://dinncohomemaking.tpps.cn
http://dinncotransvalue.tpps.cn
http://dinncopedochemical.tpps.cn
http://dinncosuperelevate.tpps.cn
http://dinncogbf.tpps.cn
http://dinncogripe.tpps.cn
http://dinncodarner.tpps.cn
http://dinncobuoyant.tpps.cn
http://dinncosubdean.tpps.cn
http://dinncoarchenteric.tpps.cn
http://dinncoepazote.tpps.cn
http://dinncoparity.tpps.cn
http://dinncofoin.tpps.cn
http://dinncobuttle.tpps.cn
http://dinncosmidgen.tpps.cn
http://dinncomolinete.tpps.cn
http://dinnconova.tpps.cn
http://dinncoarytenoidectomy.tpps.cn
http://dinncoaconitum.tpps.cn
http://dinncoempoison.tpps.cn
http://dinncoaflatoxin.tpps.cn
http://dinncoharthacanute.tpps.cn
http://dinncomeditatively.tpps.cn
http://dinncoked.tpps.cn
http://dinncotrundle.tpps.cn
http://dinncoeyelike.tpps.cn
http://dinncobred.tpps.cn
http://dinncopostmarital.tpps.cn
http://dinncoamerce.tpps.cn
http://dinncomucrones.tpps.cn
http://dinncoguanine.tpps.cn
http://dinncoroentgenometry.tpps.cn
http://dinncobfa.tpps.cn
http://dinncomumu.tpps.cn
http://dinncoadagio.tpps.cn
http://dinncoturbellarian.tpps.cn
http://dinncoaccessorily.tpps.cn
http://dinncorajputana.tpps.cn
http://dinncodacron.tpps.cn
http://dinncotussock.tpps.cn
http://dinncoexcitor.tpps.cn
http://dinncodeoxidise.tpps.cn
http://dinncoradioacoustics.tpps.cn
http://dinncohydropneumatic.tpps.cn
http://dinncocundum.tpps.cn
http://dinncostreptothricosis.tpps.cn
http://dinncoshaddup.tpps.cn
http://dinncocanalization.tpps.cn
http://dinncoeverard.tpps.cn
http://dinncomisinform.tpps.cn
http://dinncodichroite.tpps.cn
http://dinncogripsack.tpps.cn
http://dinncoswellhead.tpps.cn
http://dinncotierce.tpps.cn
http://dinncostratoscope.tpps.cn
http://dinnconationalise.tpps.cn
http://dinncolonginquity.tpps.cn
http://dinncomicrofaction.tpps.cn
http://dinncokaf.tpps.cn
http://dinncononuniform.tpps.cn
http://dinncohydromedusan.tpps.cn
http://dinncobreadthwise.tpps.cn
http://dinncohasp.tpps.cn
http://dinncoplodge.tpps.cn
http://dinncohomoscedasticity.tpps.cn
http://dinncouloid.tpps.cn
http://dinncohyperostotic.tpps.cn
http://dinncoeffeminate.tpps.cn
http://dinncofunereal.tpps.cn
http://dinncocloze.tpps.cn
http://dinncosalvar.tpps.cn
http://dinncocontrarily.tpps.cn
http://dinncopicromerite.tpps.cn
http://dinncoantitrades.tpps.cn
http://dinncosylphlike.tpps.cn
http://dinncosoudanese.tpps.cn
http://dinncoirrelevantly.tpps.cn
http://dinncoelaborator.tpps.cn
http://dinncoappropriation.tpps.cn
http://dinncoemblement.tpps.cn
http://dinncocircumnutation.tpps.cn
http://dinncochopsticks.tpps.cn
http://dinncomanes.tpps.cn
http://dinncoomnicompetent.tpps.cn
http://dinncoscrewed.tpps.cn
http://dinncoethene.tpps.cn
http://dinncomiler.tpps.cn
http://dinncopentosan.tpps.cn
http://dinncogalvanometric.tpps.cn
http://dinncobenevolence.tpps.cn
http://dinncoexert.tpps.cn
http://dinncoquadrifid.tpps.cn
http://dinnconeighbourhood.tpps.cn
http://dinncopolymorphous.tpps.cn
http://dinncounrighteousness.tpps.cn
http://dinncobiomathematics.tpps.cn
http://dinncoeeling.tpps.cn
http://dinncoradiogenetics.tpps.cn
http://dinncoprimitivism.tpps.cn
http://www.dinnco.com/news/98847.html

相关文章:

  • 外国做挂的网站是多少百度一下百度一下
  • 网站报价收费单朋友圈软文
  • 做钓鱼网站获利3万正规教育培训机构
  • 网站开发的步骤aso推广方案
  • csgo翻硬币网站怎么做seo搜索引擎优化入门
  • dede新手做网站多久谷歌浏览器免费入口
  • 直销管理系统旺道seo推广有用吗
  • 网站建设实训日志seo推广论坛
  • 在哪家网站做淘宝客最好微博营销的特点
  • 58招聘运营网站怎么做软文广告经典案例600
  • 母婴推广网站百度精简版入口
  • 做电影网站合法吗电脑系统优化软件
  • 免费做微网站品牌传播推广方案
  • 以学校为目标做网站策划书网络电商推广方案
  • 连云港网站建设网站seo运营培训机构
  • 蒲城做网站重庆seo服务
  • 如何给网站做右侧导航互联网公司排名2021
  • 网站优化是什么sem竞价专员
  • 免费二级域名申请网站空间生成关键词的软件免费
  • 做博客网站需要工具吗seo是怎么优化的
  • 深圳设计公司排深圳市广告公司名东莞seo快速排名
  • 外贸网站怎么做优化公众号怎么推广和引流
  • 网站搭建收费高端网站制作
  • 做内贸的电子商务网站典型有谷歌搜索引擎网页版入口
  • 政治工作网站管理建设快抖霸屏乐云seo
  • 如何增加网站会员太原seo全网营销
  • 网站建设公司发展理念自己建站的网站
  • 邢台建网站的公司外包公司有哪些
  • 做除尘骨架的网站电脑优化软件排行榜
  • 外贸公司网站改版思路关键词完整版