Codeforces Round #506 (Div. 3) E
Codeforces Round #506 (Div. 3) E
dfs+贪心
#include<bits/stdc++.h> using namespace std;
typedef long long ll;
const int maxn = ;
int n,u,v;
int ans;
vector<int>M[maxn];
int dfs(int cur,int pre)
{
int ret = ;
for(int i=;i<M[cur].size();i++)
{
int nex = M[cur][i];
if(pre == nex)continue;
ret = min(ret,dfs(nex,cur));
}
if(ret == && cur != && pre != )ans++;
return (ret+)%;
}
int main()
{
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&u,&v);
M[u].push_back(v);
M[v].push_back(u);
}
dfs(,);
cout<<ans<<endl;
}
Codeforces Round #506 (Div. 3) E的更多相关文章
- Codeforces Round #506 (Div. 3) 题解
Codeforces Round #506 (Div. 3) 题目总链接:https://codeforces.com/contest/1029 A. Many Equal Substrings 题意 ...
- Codeforces Round #506 (Div. 3) D-F
Codeforces Round #506 (Div. 3) (中等难度) 自己的做题速度大概只尝试了D题,不过TLE D. Concatenated Multiples 题意 数组a[],长度n,给 ...
- Codeforces Round #506 (Div. 3)
题解: div3水的没有什么意思 abc就不说了 d题比较显然的就是用hash 但是不能直接搞 所以我们要枚举他后面那个数的位数 然后用map判断就可以了 刚开始没搞清楚数据范围写了快速乘竟然被hac ...
- Codeforces Round #506 (Div. 3) D. Concatenated Multiples
D. Concatenated Multiples You are given an array aa, consisting of nn positive integers. Let's call ...
- Codeforces Round #506 (Div. 3) C. Maximal Intersection
C. Maximal Intersection time limit per test 3 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #506 (Div. 3) - D. Concatenated Multiples(思维拼接求是否为k的倍数)
题意 给你N个数字和一个K,问一共有几种拼接数字的方式使得到的数字是K的倍数,拼接:“234”和“123”拼接得到“234123” 分析: N <= 2e5,简单的暴力O(N^2)枚举肯定超时 ...
- 【Codeforces Round #506 (Div. 3) 】
A:https://www.cnblogs.com/myx12345/p/9844334.html B:https://www.cnblogs.com/myx12345/p/9844368.html ...
- Codeforces Round #506 (Div. 3)B.Creating the Contest(dp)
B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #506 (Div. 3) A-C
CF比赛题解(简单题) 简单题是指自己在比赛期间做出来了 A. Many Equal Substrings 题意 给个字符串t,构造一个字符串s,使得s中t出现k次;s的长度最短 如t="c ...
随机推荐
- 23.协程的使用场景,高I/O密集型程序
import time def one_hundred_millionA(): start_time = time.time() i = 0 for _ in range(100000000): i ...
- Dp状态设计与方程总结
1.不完全状态记录<1>青蛙过河问题<2>利用区间dp 2.背包类问题<1> 0-1背包,经典问题<2>无限背包,经典问题<3>判定性背包问 ...
- pipenv虚拟环境
虚拟环境 之前用的 virtualenv +virtualenvwrapper 今天在学习 flask 框架 用到了pipenv pipenv Pipfile 文件是 TOML 格式而不是 ...
- hive 取排行第二的工资
CREATE TABLE employee( id INT , salary INT ); INSERT INTO employee , UNION ALL , UNION ALL ,; SELECT ...
- Codeforces Round #535 (Div. 3) F
F. MST Unification 题目传送门 题意: 给你n个顶点,m条边:保证没有重边,其中存在多个MST(最小生成树), 你可以修改一些边的权值,让其中有且仅有一个最小生成树,求最少操作的边数 ...
- 32.Group Anagrams(相同元素的不同组合)
Level: Medium 题目描述: Given an array of strings, group anagrams together. Example: Input: ["eat ...
- JavaScript的进制转换
先介绍两个API: 一.number 类型的 toString 方法 语法 JavaScript: numberObject.toString( [ radix ] ) 参数 参数 描述 radix ...
- 源码分析--HashMap(JDK1.8)
在JDK1.8中对HashMap的底层实现做了修改.本篇对HashMap源码从核心成员变量到常用方法进行分析. HashMap数据结构如下: 先看成员变量: 1.底层存放数据的是Node<K,V ...
- wxstring与其他类型转换
wxstring与其他类型转换 1.1 int to wxString: wxString str = wxString::Format(wxT("%i"),myInt); 1.2 ...
- 115-基于TI TMS320DM6467T Camera Link 机器视觉 智能图像分析平台
基于TI TMS320DM6467无操作系统Camera Link智能图像分析平台 1.板卡概述 该板卡是我公司推出的一款具有超高可靠性.效率最大化.无操作系统的智能视频处理卡,是机器视觉开发上的首选 ...