Codeforces Round #290 (Div. 2)
来源:互联网 发布:羽毛球软件 编辑:程序博客网 时间:2024/04/27 17:35
B. Fox And Two Dots http://codeforces.com/contest/510/problem/B
简单的DFS
#include<iostream>#include<string.h>using namespace std;char st[55][55];int vis[55][55] , turn[4][2] ={0,1,0,-1,1,0,-1,0};int n , m , flag;void dfs(int x , int y , char ch, int limit){ if(flag) return; vis[x][y] = 1; for(int i = 0 ; i < 4 ; i++) { if(limit == i) continue; int xx = turn[i][0] + x; int yy = turn[i][1] + y; if(xx >= 0 && yy >= 0 && xx < n && yy < m && st[xx][yy] == ch) { if(vis[xx][yy] == 1) { flag = 1; return; } else { if(i == 1) dfs(xx,yy,ch,0); if(i == 0) dfs(xx,yy,ch,1); if(i == 2) dfs(xx,yy,ch,3); if(i == 3) dfs(xx,yy,ch,2); } } }}int main(){ cin >> n >> m; for(int i = 0 ; i < n ; i++) cin >>st[i]; for(int i = 0 ; i < n ;i++) for(int j = 0 ; j < m ; j++) { memset(vis,0,sizeof(vis)); dfs(i,j,st[i][j],-1); if(flag) { cout << "Yes" << endl; return 0; } } cout << "No" <<endl; return 0;}
A. Fox And Snake http://codeforces.com/contest/510/problem/A
签名题 输出蛇
#include<iostream>using namespace std;int main(){ int n , m ; while(cin >> n >> m) { for(int i = 1 ; i <= n ;i++) { for(int j = 1 ; j <= m ;j++) { if(i%2) cout << "#" ; else { if(i%4 == 0 && j == 1) cout << "#" ; else if(i%2 == 0 && j == m && i%4 !=0) cout << "#" ; else cout << "."; } } cout << endl; } } return 0;}
0 0
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2)D
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- go method使用
- HDU 1116 Play on Words(欧拉通路)
- 设计模式在游戏中的应用--简单工厂模式(一)
- 把一个Js功能块封装到一个JS对象中
- CStatic控件的基本使用
- Codeforces Round #290 (Div. 2)
- apk的签名和包名
- xcode6中如何对scrollview进行自动布局(autolayout)
- java clone
- 最短路径(四)—Bellman-Ford的队列优化(邻接表)
- 求1+2+....+n
- Aho-Corasick算法学习
- 使用Jackson2.4解析属性首字母为大写的JSON串
- PHP实现伪造邮件攻击