C. Andryusha and Colored Balloons】的更多相关文章

C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he…
C. Andryusha and Colored Balloons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he…
地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and…
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权! 题目链接:codeforces781A Andryusha and Colored Balloons 正解:构造+结论 解题报告: 考虑答案显然是$max(度数)+1$,这个似乎很好想,对于每个点我需要保证与之相邻的所有点颜色互不相同且与自己不同,那么需要…
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 ],V[maxn<<],dis[maxn],ans; void dfs(int now,int fa) { ; for…
C. Andryusha and Colored Balloons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he…
Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n squares connected with (n - 1) bidirectional paths in such a way that any square is reachable…
题意: Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n squares connected with (n - 1) bidirectional paths in such a way that any square is reacha…
Link 题意: 给出一棵树,要求为其染色,并且使任意节点都不与距离2以下的节点颜色相同 思路: 直接DFS.由某节点出发的DFS序列,对于其个儿子的cnt数+1,那么因为DFS遍历的性质可保证兄弟结点的颜色不同,只需考虑当前节点是否与父亲结点和父亲的父亲结点颜色是否相同. /** @Date : 2017-05-09 22:37:25 * @FileName: 782C DFS.cpp * @Platform: Windows * @Author : Lweleth (SoundEarlf@g…
从任意点出发,贪心染色即可. #include<cstdio> #include<algorithm> using namespace std; int v[200010<<1],next[200010<<1],first[200010],e; void AddEdge(int U,int V) { v[++e]=V; next[e]=first[U]; first[U]=e; } bool vis[200010]; int n,col[200010]; v…