#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#define INF 0x3f3f3f3f
#define IMAX 2147483646
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
int n,u,v,t,root;
int f[1511][2],vis[1511];
int e[1511][1511], l[1511];
void dp(int x) {
for (int i = 0; i < l[x]; i++) {
dp(e[x][i]);
f[x][1] += min(f[e[x][i]][0], f[e[x][i]][1]);
f[x][0] += f[e[x][i]][1];
}
}
int main() {
while (scanf("%d", &n) != EOF) {
memset(l, 0, sizeof(1));
memset(vis, 0, sizeof(vis));
for (int i = 0; i < n; i++) {
scanf("%d:(%d)", &u, &t);
l[u] = t;
f[u][0] = 0;
f[u][1] = 1;
for (int j = 0; j < l[u]; j++)
scanf("%d", &e[u][j]), vis[e[u][j]] = 1;
}
for (int i = 0; i < n; i++)
if (vis[i] == 0)root = i;
dp(root);
printf("%d\n", min(f[root][0], f[root][1]));
}
return 0;
}
相关推荐
R语言基础之R语言入门
R语言最初是由新西兰奥克兰大学统计系的教授Ross Ihaka和Robert Gentleman在S语言基础上开发完成的。是一门解释性语言。在我看来R语言是一门数学性极强的语言,或者说这是一门为数学而生的语言,因为其具有极其出色的计算与统计分析能力...
POJ 1463 树状dp
Strategic game Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 6629 Accepted: 3058 Description Bob enjoys playing computer games, especially strategic games,...
用 Python 和 uiautomation 实现微信批量发送
思路是这样,将要发送的人员名单(包括称呼)以及发送内容都维护到Excel里,程序运行时读取Excel里内容,自动搜索人员姓名(微信昵称或备注名),填入要发送的内容,拼接上称呼(如果需要的话)自动点击发送,这样轮巡直至名单人员全部发送完成。、
poj1463 Strategic game (树状dp)
Strategic game Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 5498 Accepted: 2484 Description Bob enjoys playing computer games, especially strategic game
GoPro官方API实战:从蓝牙配对到Wi-Fi流媒体,构建跨平台控制应用
本文详细解析了GoPro官方API的开发实践,涵盖蓝牙配对、Wi-Fi流媒体控制等关键技术。通过实战案例,指导开发者如何构建跨平台控制应用,解决设备发现、指令解析、视频流传输等核心问题,并分享Android平台迁移经验与常见问题排查方法。
基于光电传感的非接触式酒精浓度检测系统设计与实现
本文详细介绍了基于光电传感技术的非接触式酒精浓度检测系统设计与实现。系统利用940nm红外LED和OPT101光电传感器,结合朗伯-比尔定律,通过STM32微控制器进行信号采集与处理,实现了快速、准确的酒精浓度测量,测量精度达±1%,适用于工业检测和便携式应用场景。
poj 1463 Strategic game 树状dp
Strategic game Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 6607 Accepted: 3047 Description Bob enjoys playing computer games, especially strategic
如何在Hyper-V、Virtual PC等虚拟机中使用USB设备
今天网盾科技给大家分享一篇在Hyper-V、Virtual PC等虚拟机中使用USB Over network软件用USB设备的方法。 当前Hyper-V Server与Microsoft Virtual PC的虚拟机,不支持USB的设备,如果你有USB设备需要在虚拟机中使用,例如USB的加密狗、智能卡、网上银行的U盾等,可以通过USB Over Network软件,通过网络,使用USB设备。 USB Over Network是一款“客户/服务器”软件,是这么一款功能强大 USB 设备共享软件。它使用方
poj-1463 Strategic game(树状DP入门)
https://vjudge.net/problem/POJ-1463 题意:一棵树,放哨兵站岗,如果有一个点放置了兵,那么与其相连的所有点都能被监视,求树的所有点都被监视且放置哨兵数目最少。 思路:dp[maxn][2] dp[i][0]表示不选取该点,dp[i][1]表示选取该点。 若该点不选取,则其子节点必须都被选取。 若该点选取,则应选取min(dp[son][0],dp[son...
【记录】游戏体验报告怎么写(自我成长篇)
2019年3月更新: 这个倒是不用推翻,我个人虽然写的东西还是有一些偏差的,但是“表哥”说的倒是没毛病的,这篇主要是为了记录用,具体的干货也有,都在图片里,请自行提取 =====18年初原答案 作为一个游戏策划新人,游戏分析可能抓不到点子上,试着总结记录一下游戏体验报告分析的成长(因为水平不同,视野可能也不一样,也许之后几年回头看这些东西都是小儿科或者是错误的,所以只写出当下的想...
RK3576 PCIE接口调试:基于RTL8111HS的网卡驱动移植
检查项方法电源电压复位时序检查设备树 reset-gpios链路速率设备识别lspci -vvv驱动加载。
POJ 1463 Strategic game
POJ 1463 Strategic game /** 树状dp POJ 1463 Strategic game */ #include #include #include #include #include #define ll long long #define maxn 1505 using namespace std; vector v[maxn]; int dp[maxn][2];
基于Matlab的磁力计校准(附源码)
磁力计沿传感器的 X、Y 和 Z 轴检测磁场强度。精确的磁场测量对于传感器融合以及确定航向和方向至关重要。为了用于航向和方向计算,需要校准典型的低成本MEMS磁力计,以补偿环境噪声和制造缺陷。一、理想磁力计理想的三轴磁力计沿正交 X、Y 和 Z 轴测量磁场强度。在没有任何磁干扰的情况下,磁力计读数测量地球磁场。如果在传感器通过所有可能的方向旋转时进行磁力计测量,则测量值应位于球体上。球体的半径是磁场强度。要生成磁场样本,请使用对象。出于这些目的,可以安全地假设每个方向的角速度和加速度为零。
(探讨贴)POJ 1463 树形DP解法的不正确性
POJ1463是一个典型的树状DP题。 通常解法如下代码所示: using namespace std; const int maxn=1502; int d[maxn][2]; int pre[maxn]; int childcnt[maxn]; int n; void dp(int cur){ if(d[cur][0]>=0||d[cur][1]>=0...
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
树状dp入门题合集
题目:POJ1463 POJ3342 Codeforces1084D Codeforces1118F1 POJ1655 - POJ1463 题意:原题意是让你选择尽可能少的点,选择的这些点和它最临近点加起来可以涵盖所有点。换一种离散数学上缅甸说法,就是给你一棵树(树是一种连通无回路的图),让你把这棵树变成一个二部图,然后求两部分哪个部分顶点。 思路:树(记忆)形(化)d(搜)p(索),从任一个点出...
pscad IEEE标准系统搭建说明
pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。
POJ1463 Strategic game 树形dp
http://poj.org/problem?id=1463 Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following p...
jdk-8u144-linux-x64.tar.gz.
该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包
POJ-1463 树形DP
Description Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defe...
POJ 1463
Strategic game Time Limit: 2000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Description Bob enjoys playing computer games, especially strategic games, but
poj 1463 Strategic game DP
题目地址:http://poj.org/problem?id=1463 题目: Strategic game Time Limit:2000MS Memory Limit:10000K Total Submissions:7929 Accepted:3692 Description Bob enjoys playing c...
POJ 1463 Strategic game(树形dp入门)
Strategic game Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must ...
POJ Strategic game(树形DP)
题目链接:http://poj.org/problem?id=1463 其实这个题目也是比较水的一个树状DP,和上面一篇博客思路基本上差不多,甚至动态方程都差不多 开始建立树的时候,直接建立树,建树的时候直接让大的成为小的子树,由于题目说了这是一棵树,所以 就不用担心直接建树就好了,最后从0(根)号节点DFS即可! 每个子树的根节点可有两个状态,要么安排士兵要么不安排,如果安排,那么子节点
pku1463 Strategic game
http://poj.org/problem?id=1463 DP,树状DP,或二分图匹配 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <vector> 5 using namespace std; 6 7 ...
POJ 1463 Strategic game (树形DP)
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a mediev...
poj 1463(树形dp)
题目: Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a me...
POJ1463Strategic game题解动态规划DP
Strategic gameTime Limit: 2000MS Memory Limit: 10000KTotal Submissions: 2096 Accepted: 870DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has th
5万+



被折叠的 条评论
为什么被折叠?



