Codeforces Round #290 (Div. 2) B (dfs)】的更多相关文章

题目链接: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; ][]={, , , , -, , , -};…
C. Fox And Names 题目连接: http://codeforces.com/contest/510/problem/C Description Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in…
B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains a dot that ha…
http://codeforces.com/problemset/problem/510/B #include "cstdio" #include "cstring" int r,c; ][]; ][]; int mark; ]={,-,,},dy[]={,,,-}; int judge(int x,int y) { ||x>=r||y<||y>=c) ; ; } void dfs(int x,int y,int perX,int perY) {…
题目传送门 /* DFS:每个点四处寻找,判断是否与前面的颜色相同,当走到已走过的表示成一个环 */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <map> #include <algorithm> #include <vector> #include <set> #include <…
E. Fox And Dinner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai year…
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/377/A 题解: 有tot个空格(输入时统计),把其中k个空格变为wall,问怎么变才能使得剩下的空格依然为连通的.把问题反过来,其实就是求tot-k的连通图.dfs:在搜索过的空格中做个标记,同时更新连通个数. 代码如下: #include<cstdio>//hdu3183 CodeForces 377A dfs #include<cstring> #include<cmath&g…
http://codeforces.com/contest/510/status/B 题目大意 给一个n*m  找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 所以wa 改了AC #include<cstdio> #include<map> //#include<bits/stdc++.h> #include<vector> #include<stack> #include<iostream>…