cf B George and Cards
题意:给你一个只有‘.’和'#'的n*n的格子,问所有的'#'是不是只属于一个十字叉,如果不是输出NO,否则输出YES。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n;
char g[][];
bool vis[][]; int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%s",g[i]);
}
for(int i=; i<=n; i++)
{
for(int j=; j<n; j++)
{
if(g[i][j]=='#')
{
bool flag=false;
if(g[i+][j-]=='#'&&g[i+][j]=='#'&&g[i+][j+]=='#'&&g[i+][j]=='#'&&i+<=n&&j->=)
{
flag=true;
g[i+][j-]='.';
g[i+][j]='.';
g[i+][j+]='.';
g[i+][j]='.';
g[i][j]='.';
}
else if(g[i+][j+]=='#'&&g[i][j+]=='#'&&g[i][j+]=='#'&&g[i-][j+]=='#'&&j+<n&&i+<=n&&i->=)
{
flag=true;
g[i+][j+]='.';
g[i][j+]='.';
g[i][j+]='.';
g[i-][j+]='.';
g[i][j]='.';
}
else if(g[i-][j]=='#'&&g[i+][j]=='#'&&g[i][j-]=='#'&&g[i][j+]=='#'&&j->=&&i+<=n&&i->=&&j+<n)
{
flag=true;
g[i-][j]='.';
g[i+][j]='.';
g[i][j-]='.';
g[i][j+]='.';
g[i][j]='.';
}
else if(g[i-][j]=='#'&&g[i-][j]=='#'&&g[i-][j-]=='#'&&g[i-][j+]=='#'&&j->=&&i+<=n&&i->=&&j+<n)
{
flag=true;
g[i-][j]='.';
g[i-][j]='.';
g[i-][j-]='.';
g[i-][j+]='.';
g[i][j]='.';
}
else if(g[i][j-]=='#'&&g[i][j-]=='#'&&g[i-][j-]=='#'&&g[i+][j-]=='#'&&j->=&&i+<=n&&i->=&&j+<n)
{
flag=true;
g[i][j-]='.';
g[i][j-]='.';
g[i-][j-]='.';
g[i+][j-]='.';
g[i][j]='.';
}
if(!flag)
{
printf("NO\n");
return ;
}
}
}
}
printf("YES\n");
return ;
}
cf B George and Cards的更多相关文章
- cf E. George and Cards
http://codeforces.com/contest/387/problem/E 题意:给你n个数,然后在输入k个数,这k个数都在n个数中出现,进行每一次操作就是在n个数中选择长度为w的连续序列 ...
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
- Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
题目链接: 题目 E. George and Cards time limit per test:2 seconds memory limit per test:256 megabytes 问题描述 ...
- Codeforces 387E George and Cards
George and Cards 我们找到每个要被删的数字左边和右边第一个比它小的没被删的数字的位置.然后从小到大枚举要被删的数, 求答案. #include<bits/stdc++.h> ...
- cf 546C Soldier and Cards
题目链接:C. Soldier and Cards Two bored soldiers are playing card war. Their card deck consists of exact ...
- George and Cards
Codeforces Round #227 (Div. 2) E:http://codeforces.com/contest/387/problem/E 题意:给你一个n个数的序列,然后给你一个标准序 ...
- cf D George and Interesting Graph
题意:给你一个有趣图的定义:在这个图中有一个根,根与每个点都有边和回边,除了根之外,其他的点的出度和入度都为2,然后给你一个图让你经过几步操作可以使此图变为有趣图,操作为:删边或者加边. 思路:枚举根 ...
- cf C. George and Number
http://codeforces.com/problemset/problem/387/C 题意:给你一个大数,让你求个集合,可以通过操作得到这个数,求集合中个数最大值,操作 :从集合中任意取两个数 ...
- cf B George and Round
题意:输入n,m,下一行为n个数a1<a2<a3......<an:然后再输入m个数b1<=b2<=b3<.....<=bm: 每个ai都必须在b中找到相等的 ...
随机推荐
- python的私有变量解析
在内的内部定义并使用,外部无法訪问,以双下划线作为前作,定义后被python转为 _classname__变量名了 ------------------------------------------ ...
- [AngularJS + Webpack] Requiring CSS & Preprocessors
Making your CSS modular is a difficult thing to do, but using Webpack makes this so much easier. By ...
- Map 迭代 两种方法
Map 迭代 两种方法 Map<String, String> map=new HashMap<String,String>(); map.put("1", ...
- iOS UIKit:Auto Layout
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...
- springmvc xml 空模板
<?xml version="1.0" encoding="UTF-8"?><!-- Bean头部 --><beans xmlns ...
- Maven Integration for Eclipse 正确地址
m2eclipse has moved from sonatype to eclipse. The correct update site is http://download.eclipse.org ...
- Android手机修改Hosts的方法
Android手机是和Google帐号紧密联系的,由于中国的操蛋情况,很多时候Google帐号无法登录,导致Android市场无法使用. 在电脑上我们通过修改Hosts方法可以解决Google帐号的登 ...
- SGU 106.Index of super-prime
时间限制:0.25s 空间限制:4M 题目大意: 在从下标1开始素数表里,下标为素数的素数,称为超级素数(Super-prime),给出一个n(n<=10000) ...
- phpcms V9 数据模型基类(转)
转自:http://www.cnblogs.com/Braveliu/p/5100421.html 在学习<phpcms V9首页模板文件解析>的第七步,我们看到content_model ...
- Android 视图切换库的使用 - SwitichLayout
要点: 1. SwitichLayout 原理和基本特效展示 - 设计上和基本特效 2. SwitchLayout 的用法 - SwitchLayout 的基本配置和用法 3. SwithLayout ...