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

烟台的网站建设网站建设需要几个人

烟台的网站建设,网站建设需要几个人,阀门专业网站建设,建设本地网站description 权限题。 树上\(n\)个节点每个节点都有一种物品#xff0c;每种物品有其价值#xff0c;价格#xff0c;数量#xff0c;只能买一个连通块中的物品#xff0c;求\(m\)元能买到物品价值的最大值。 data range \[ n\le 500,m\le 4000,T\le 5,c_i\le m\] solutio…description 权限题。 树上\(n\)个节点每个节点都有一种物品每种物品有其价值价格数量只能买一个连通块中的物品求\(m\)元能买到物品价值的最大值。 data range \[ n\le 500,m\le 4000,T\le 5,c_i\le m\] solution 紧跟\(YCB\)聚聚的步伐 首先可以想到以每个点为根做树形依赖背包 树形依赖背包 设\(f[i][j]\)表示在子树\(i\)中买了价值为\(j\)的物品 如果直接对父亲转移是每次\(O(nc^2)\)的 我们把每个连通块考虑成一条路径如果选某个点就前往这个点\(dfn\)序的下一个点 如果不选就跳过整棵子树做转移 这样做再加上多重背包的单调队列优化可以达到每次\(O(nc)\) 总复杂度为\(O(n^2c)\) 然后套一下点分治或者\(dsu\ on\ tree\)都可以 code #includebits/stdc.h #includealgorithm #includeiostream #includecstdlib #includeiomanip #includecstring #includecomplex #includevector #includecstdio #includestring #includebitset #includectime #includecmath #includequeue #includestack #includemap #includeset #define FILE a #define mp make_pair #define pb push_back #define RG register #define il inline using namespace std; typedef unsigned long long ull; typedef vectorintVI; typedef long long ll; typedef double dd; const dd eps1e-10; const int mod1e97; const int N510; const int M4010; const dd piacos(-1); const int infmod; const ll INF1e181; const ll P100000; il ll read(){RG ll data0,w1;RG char chgetchar();while(ch!-(ch0||ch9))chgetchar();if(ch-)w-1,chgetchar();while(ch9ch0)datadata*10ch-48,chgetchar();return data*w; }il void file(){srand(time(NULL)rand());freopen(FILE.in,r,stdin);freopen(FILE.out,w,stdout); }int n,m,w[N],c[N],d[N],ans; int head[N],nxt[N1],to[N1],cnt; int sz[N],son[N],dfn[N],fw[N],cntw; void dfs1(int u,int fa){sz[u]1;son[u]0;for(RG int ihead[u];i;inxt[i]){RG int vto[i];if(vfa)continue;dfs1(v,u);sz[u]sz[v];if(sz[son[u]]sz[v])son[u]v;} } void dfs2(int u,int fa){dfn[u]cntw;fw[cntw]u;for(RG int ihead[u];i;inxt[i]){RG int vto[i];if(vfa||vson[u])continue;dfs2(v,u);}if(son[u])dfs2(son[u],u); }int dp[N][M],q[M],l,r; il void upd(int a,int b){aab?a:b;} il void work(int *f1,int *f2,int u){for(RG int i0,ret;ic[u];i){l1;r0;for(RG int j0;j*c[u]im;j){while(lrj-q[l]d[u])l;retlr?-inf:f2[q[l]*c[u]i](j-q[l])*w[u];upd(f1[j*c[u]i],ret);while(lrf2[q[r]*c[u]i]f2[j*c[u]i](q[r]-j)*w[u])r--;q[r]j;}} }void dsu(int u,int fa,int k){for(RG int ihead[u];i;inxt[i]){RG int vto[i];if(vfa||vson[u])continue;dsu(v,u,0);}if(son[u])dsu(son[u],u,1);for(RG int i0;im;i)dp[fw[dfn[u]sz[u]]][i]-inf;dp[fw[dfn[u]sz[u]]][0]0;for(RG int idfn[u]sz[u]-sz[son[u]]-1;idfn[u];i--){RG int xfw[i];for(RG int j0;jm;j)dp[x][j]-inf;if(x!u)for(RG int j0;jm;j)upd(dp[x][j],dp[fw[isz[x]]][j]);work(dp[x],dp[fw[i1]],x);}for(RG int i0;im;i)upd(ans,dp[u][i]);if(k){for(RG int i0;im;i)dp[u][i]-inf;for(RG int i0;im;i)upd(dp[u][i],dp[fw[dfn[u]sz[u]]][i]);work(dp[u],dp[fw[dfn[u]1]],u);} }int main() {RG int Tread();while(T--){nread();mread();ans-inf;fw[n1]n1;cntcntw0;memset(head,0,sizeof(head));for(RG int i1;in;i)w[i]read();for(RG int i1;in;i)c[i]read();for(RG int i1;in;i)d[i]read();for(RG int i1,u,v;in;i){uread();vread();to[cnt]v;nxt[cnt]head[u];head[u]cnt;to[cnt]u;nxt[cnt]head[v];head[v]cnt;} dfs1(1,0);dfs2(1,0);dsu(1,0,0); printf(%d\n,ans);}return 0; }转载于:https://www.cnblogs.com/cjfdf/p/9540057.html
http://www.yutouwan.com/news/57992/

相关文章:

  • 个人做淘宝客网站好做吗东莞网络优化
  • 广东省建设教育协会官方网站电子展厅
  • 影视网站建设平台郑州百度推广外包
  • 潍坊网站建设首荐创美网络怎么做品牌推广和宣传
  • 检察院门户网站建设网页布局设计说明
  • 自贡住房和城乡建设厅网站网站怎么做切换图片
  • 什么是展示型网站建设网站如何做超级链接
  • 接做施工图的网站seo推广优化平台
  • 网站建设要求卖货到海外的免费平台
  • asp网站配置典型的网站开发人员
  • 沈阳做公司网站的公司无锡企业网站设计公司
  • 工作做ppt课件的网站2000个免费货源网站
  • 网站建设淘宝模板宁波企业seo外包
  • 怎么筛选一家做网站做的好的公司重庆网站建设优斗士
  • 响应式网站开发哪家好设计精美的中文网站
  • 无锡公司建立网站做跨境的网站有哪些
  • 网站建设能解决哪些问题大连甘井子区地图
  • 西安网站排名优化做效果图网站有哪些
  • 微网站缺点网站重定向怎么做
  • 企业网站建设需要哪些步骤科技部网站
  • 视频网站开发教程我花钱买了一个函授本科
  • app网站建设需要什么软件最有性价比的网站建设
  • 网站建设技术架构和语言网站建设过程与思路
  • 推广app网站企业网站设计报名
  • 网站开发建设与维护邯郸网站建设安联网络公司
  • 著名网站设计师c 手机版网站开发
  • 电子商务与网站建设嘉兴网站建设哪家做得好
  • 网站监控 重启企业官网如何设计
  • 网站如何做搜狗搜索引擎上海闵行邮编
  • 网站建设 中企动力wordpress 优酷去广告插件