Codeforces Round #228 (Div. 2) B. Fox and Cross
来源:互联网 发布:好听的傣族网络歌曲 编辑:程序博客网 时间:2024/05/16 17:27
这一题也是比较简单的,就是两层循环判断即可,没遇到一个‘#’就判断周围的'#'是否满足十字条件,若不满足,输出"NO"结束,否则就令这几个’#‘都为'.',注意要对每个位置都进行判断、处理
代码如下:
#include <algorithm>#include <iostream>#include <string>#include <vector>#define maxn 110using namespace std;char a[maxn][maxn];int main(void){ int n; while(cin >> n){ for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> a[i][j]; for(int i=0; i<n-2; ++i) for(int j=1; j<n-1; ++j){ if(a[i][j] == '#'){ if(a[i+1][j]=='#' && a[i+2][j]=='#' && a[i+1][j-1]=='#' && a[i+1][j+1]=='#'){ a[i][j]='.'; a[i+1][j]='.'; a[i+2][j]='.'; a[i+1][j-1]='.'; a[i+1][j+1]='.'; } else{ cout << "NO" << endl; return 0; } } } for(int i=0; i<n; ++i) if(a[i][0]=='#' || a[i][n-1]=='#'){ cout << "NO" << endl; return 0; } for(int j=1; j<n-1; ++j) if(a[n-2][j]=='#' || a[n-1][j]=='#'){ cout << "NO" << endl; return 0; } cout << "YES" << endl; } return 0;}
0 0
- Codeforces Round #228 (Div. 2) B. Fox and Cross
- Codeforces Round #228 (Div. 2)B. Fox and Cross
- Codeforces Round #228 (Div. 2)B. Fox and Cross
- Codeforces Round #228 (Div. 2) B. Fox and Cross
- Codeforces Round #228 (Div. 2) B Fox and Cross(DFS)
- Codeforces Round #228 (Div. 1)-B-Fox and Minimal path
- Codeforces Round #228 (Div. 1) B. Fox and Minimal path
- Codeforces Round #290(Div.2) B.Fox And Two Dots
- B. Fox And Two Dots( Codeforces Round #290 (Div. 2))
- B. Fox And Two Dots Codeforces Round #290 (Div. 2)
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots
- Codeforces Round #290 (Div. 2) B. Fox And Two Dots
- Codeforces Round #228 (Div. 2) A. Fox and Number Game
- Codeforces Round #228 (Div. 2)A.Fox and Number Game
- Codeforces Round #228 (Div. 2)C. Fox and Box Accumulation
- Codeforces Round #228 (Div. 2)A. Fox and Number Game
- Codeforces Round #228 (Div. 2)C. Fox and Box Accumulation
- 流水账2014 02/01~02/03
- 设计模式(8) 组合模式(COMPOSITE)
- two sum
- c++ 合并图种
- Codeforces Round #228 (Div. 2) A. Fox and Number Game
- Codeforces Round #228 (Div. 2) B. Fox and Cross
- Codeforces #228 (Div. 2)C. Fox and Box Accumulation
- 1、Hello World
- 黑马程序员_16 IO流
- ClassLoader的工作原理
- 深夜乱作
- uva - 524 - Prime Ring Probl(素数环、回溯)
- [leet code] Subsets II
- Leetcode全树类问题