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 ...
随机推荐
- Recurrent Neural Network(3):LSTM Basics and 《Inside Out》
下图是Naive RNN的Recurrent Unit示意图,可以看到,在每个时间点t,Recurrent Unit会输出一个隐藏状态ht,对ht加工提取后将产生t时刻的输出yt.而在下一个时间节点t ...
- Django first()和last() F查询以及Q查询
一.first()和last() 分别返回queryset的第一项与最后一项,具体用法如下: p = Blog.objects.order_by('title').first() 等同于: try: ...
- RMQ(连续相同最大值)
http://poj.org/problem?id=3368 Frequent values Time Limit: 2000MS Memory Limit: 65536K Total Submi ...
- hdu5857 Median(模拟)
Median Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- mysql (mariadb)表结构添加修改删除方法总结
1,添加表字段 alter table table1 add ptel varchar(100) not Null; alter table table1 add id int unsigned no ...
- 安卓构架组件——向项目添加组件(Adding Components to your Project)
在开始之前,建议阅读 应用架构指南. Before getting started, we recommend reading the Architecture Components Guide to ...
- 【记录】jd-gui解析class文件 报INTERNAL ERROR
用GUI查看class文件时候出现INTERNAL ERROR 错误,是因为jd-gui解析不了该class文件,报错问题如下 解决方式:换个解析器,推荐luyten解析 下载地址:https://g ...
- quotaon - 开启关闭文件系统配额
总览 (SYNOPSIS) quotaon [ -e | d ] [ -vug ] filesystem... quotaon [ -e | d ] [ -avug ] quotaoff [ -e | ...
- vue,一路走来(14)--短信验证码框的实现(类似支付密码框)
由于项目的扩展,新增了很多功能,今天谈一下短信验证码框的实现. 思路:每个小方框其实就是单独的每一个input标签(叫假input标签),每个长度为1,然后上面再写一个大的input标签(叫真实inp ...
- go语言从例子开始之Example38.排序
Go 的 sort 包实现了内置和用户自定义数据类型的排序功能.我们首先关注内置数据类型的排序. Example: package main import ( "fmt" &quo ...