C++ 洛谷 P1273 有线电视网 题解
2024-08-27 14:13:45
很明显,这是一道树形DP(图都画出来了,还不明显吗?)
未做完,持续更新中……
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=;
int n,m;
struct edge{
int from,to,money;
int next;
}e[maxn*];
int read()
{
int x=,f=;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-;c=getchar();}
while(isdigit(c)){x=x*+c-'';c=getchar();}
return x*f;
}
int cnt=,head[maxn];
int f1[maxn][maxn],f2[maxn][maxn];
int corn[maxn];
int sum;
void edge(int x,int y,int c)
{
e[cnt].from=x;
e[cnt].to=y;
e[cnt].money=c;
e[cnt].next=head[x];
head[x]=cnt++;
}
void tree_dp(int i)
{
if(i<=n-m)
for (int j=head[u];!j;j=e[j].next)
{
tree_dp(e[i].to);
}
else { }
}
void work()
{
n=read(),m=read();
for(int i=;i<=n-m;i++)
{
int q,w;
q=read();
for(int j=;j<=q;j++)
{
int a,b;
a=read(),b=read();
addedge(i,a,b);
addedge(a,i,b);
}
}
for (int i=;i<=m;i++)
scanf("%d",c[i]),sum+=c[i];
tree_dp();
printf("%d",ans);
}
int main()
{
work();
return ;
}
最新文章
- 【转】Sublime Text3注册码(可用)
- WebMidiLink
- java-代理模式及动态代理
- call &; apply
- new[]上面居然有一个内存计数,怪不得delete[]从来不出错
- mysql wait_timeout和interactive_timeout总结
- [转] CSS direction属性简介与实际应用 ---张鑫旭
- JBoss EAP6/AS7/WildFly: How to Use Properties Files Outside Your Archive--reference
- Java并发编程深入学习
- Codeforces_499C:Crazy Town(计算几何)
- Linux 删除目录与文件
- 如何在本地搭建DVWA环境
- ExcelDna项目完整工程演示及讲解
- theano使用GPU踩坑
- NOIP模拟赛-2018.11.5
- TCP 和 UDP 在socket编程中的区别(转)
- ZooKeeper(二)Java API使用
- ZOJ 2017 Quoit Design 经典分治!!! 最近点对问题
- bat薪酬
- Hibernate中createCriteria即QBC查询的详细用法
热门文章
- 构建自己的PHP框架(Twig模板引擎)
- 本文摘录 - FlumeJava
- HDOJ 2189 悼念512四川汶川大地震遇难者——来生一起走 【生成函数】
- 解压压缩文件报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- easyui Full Layout
- 数据库访问工具 DBUtl(公孙二狗)
- WPF的逻辑树和视觉树
- git/github初级运用自如 (good)
- 【Gerrit】持续集成工具Jenkins的安装配置与使用过程中遇到的问题整理
- iOS UILabel显示html标签