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中找到相等的 ...
随机推荐
- Secant Method (Website)
Secant Method: https://www.youtube.com/watch?v=qC9xnsfOd30 Secant Method : http://mathworld.wolfram ...
- android 02 登录
activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android& ...
- QDomDocument类
QDomDocument类代表了一个XML文件 QDomDocument类代表整个的XML文件.概念上讲:它是文档树的根节点,并提供了文档数据的基本访问方法. 由于元素.文本节点.注释.指令执行等等不 ...
- 如何消除inline-block产生的元素间空隙
前端初学者可能都会碰到这个问题:有时候排版需要,会把一些块状元素的display属性设置为inline-block,如 <!-- HTML代码 --> <div class=&quo ...
- Axiom3D学习日记 4.地形,天空,雾
首先需要引用Axiom.SceneManagers.Octree.dll. 地形: 载入地形配置,从一个文件中. scene.LoadWorldGeometry( "Terrain.xml& ...
- index full scan/index fast full scan/index range scan
**************************1************************************* 索引状态: valid. N/A . ...
- iOS 代码分类
控件分类: 指示器 (ActivityIndicator) 提醒对话框 (AlertView) 按钮 (Button) 日历 (Calendar) 相机 (Camera) 透明指示层 (HUD) 图像 ...
- 对数据预处理的一点理解[ZZ]
数据预处理没有统一的标准,只能说是根据不同类型的分析数据和业务需求,在对数据特性做了充分的理解之后,再选择相关的数据预处理技术,一般会用到多种预处理技术,而且对每种处理之后的效果做些分析对比,这里面经 ...
- Codeforces Round #286 (Div. 1) 解题报告
A.Mr. Kitayuta, the Treasure Hunter 很显然的一个DP,30000的数据导致使用map+set会超时.题解给了一个非常实用的做法,由于每个点有不超过250种状态,并且 ...
- Android开发系列----sdk下载 环境准备
今天开始准备Android开发环境,FQ下载Android Studio,官网下载地址 https://developer.android.com/studio/install.html (突然发现我 ...