CF - 389 - B. Fox and Cross(贪心)
来源:互联网 发布:ipad 软件 编辑:程序博客网 时间:2024/06/01 18:12
题意:给出一个n*n的图,问这个图是否能由十字架拼成(3 ≤ n ≤ 100)。
题目链接:http://codeforces.com/problemset/problem/389/B
——>>最上面一行的#,一定是一个十字架的头部,判断该头部是否符合要求即可。
#include <cstdio>using namespace std;const int maxn = 100 + 10;char G[maxn][maxn];int main(){ int n; while(scanf("%d", &n) == 1) { int sum = 0; for(int i = 0; i < n; i++) { getchar(); for(int j = 0; j < n; j++) { G[i][j] = getchar(); if(G[i][j] == '#') sum++; } } bool ok = true; if(sum % 5) ok = false; if(ok) { for(int i = 0; i < n; i++) { if(!ok) break; for(int j = 0; j < n; j++) if(G[i][j] == '#') { if(!j || j == n-1 || i > n-3 || G[i+1][j] != '#' || G[i+1][j-1] != '#' || G[i+1][j+1] != '#' || G[i+2][j] != '#') { ok = false; break; } G[i+1][j] = G[i+1][j-1] = G[i+1][j+1] = G[i+2][j] = '.'; } } } ok ? puts("YES") : puts("NO"); } return 0;}
0 0
- CF - 389 - B. Fox and Cross(贪心)
- CF 389B:Fox and Cross
- B. Fox and Cross
- Codeforces 389B Fox and Cross(dfs)
- 模拟-codeforces-389B-Fox and Cross
- CodeForces 389B Fox and Cross
- codeforces 389b Fox and Cross
- codeforces Fox and Cross
- Fox and Cross
- codeforces Fox and Cross
- vj Fox and Cross
- Codeforces Round #228 (Div. 2) B Fox and Cross(DFS)
- 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
- CF 389A:Fox and Number Game
- CF 510B(Fox And Two Dots-图上找环)
- 新人刚入职场如何做到让人刮目相看!
- [二分查找]Compound Words uva10391
- 创建目录函数
- tdd开发学习
- Hibernate 学习总结
- CF - 389 - B. Fox and Cross(贪心)
- jquery mobile alter、confirm重写,使用popup
- hdu 1004 翻译
- www.id666.com中的免费空间
- JavaScript入门之基本语法
- cocos2dx android ndk 加载动态库(.so)
- OpenGL 学习笔记(1)
- 医院产品变畅想
- 对Image字段存取图片、文件