Codeforces Round #449 (Div. 2) C. DFS】的更多相关文章

C. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a game with little…
Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define pb push_back #define eb emplace_back…
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Are you going to Scarborough Fair? Parsley, sage, rosemary and thyme. Remember me to one who lives there. He on…
D. Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive intege…
题目链接:http://codeforces.com/contest/742/problem/E 题意: 有一个环形的桌子,一共有n对情侣,2n个人,一共有两种菜. 现在让你输出一种方案,满足以下要求: 情侣间吃不同的菜 相邻的三个人不能都吃同一种菜 输出任意一个解: 先将相邻的两个人连边,这样就满足了3个人不吃同样一种菜. 情侣间连边. 图中就不存在奇数环. 那么就一定存在解.然后DFS染色就OK 了. #include <bits/stdc++.h> using namespace std…
题目链接:http://codeforces.com/problemset/problem/510/B 题意:判断图中是否有某个字母成环 思路:直接dfs就好了,注意判断条件:若下一个字母与当前字母相同且已搜过,则存在满足题意的环 代码: #include <bits/stdc++.h> #define MAXN 60 using namespace std; int mp[MAXN][MAXN], vis[MAXN][MAXN], m, n; ][]={, , , , -, , , -};…
题目链接:http://codeforces.com/problemset/problem/377/A 题解: 有tot个空格(输入时统计),把其中k个空格变为wall,问怎么变才能使得剩下的空格依然为连通的.把问题反过来,其实就是求tot-k的连通图.dfs:在搜索过的空格中做个标记,同时更新连通个数. 代码如下: #include<cstdio>//hdu3183 CodeForces 377A dfs #include<cstring> #include<cmath&g…
C. Journey time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other…
C. Kefa and Park time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a roote…
B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output — Thanks a lot for today. — I experienced so many great things. — You gave me memories like dreams... But I have to le…