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中找到相等的 ...
随机推荐
- [RxJS] Utility operator: do
We just saw map which is a transformation operator. There are a couple of categories of operators, s ...
- alloc、init你弄懂50%了吗?
前言 这是一篇我记录对alloc.init分析思考的笔记.如果读者想看懂我的第二个思考,可能需要您至少了解内存的分段分页管理,如果您对其一点都不知道,可以先看这篇软文简单了解一下.另外很重要的一点是, ...
- jQuery ajax 传递数组到struts2
使用jQuery的$.ajax()方法进行异步交互时,如果传递的数据有数组(例如传输checkbox数据),Action中经常会接受不到数据. 此时应该注意一下data中数组的写法,例如: //组合成 ...
- Robolectric Test-Drive Your Android Code
Running tests on an Android emulator or device is slow! Building, deploying, and launching the app o ...
- node里如何查看浏览器信息
'use strict'; let http = require(`http`); http.createServer((req, res) => { console.log(req.heade ...
- SQL SERVER将指定表中的指定字段按照(,)逗号分隔
不开心呀,早知道不跳了,一跳跳坑里来了. 使用方式: DECLARE @ConsigneeAddressId INT; SET @ConsigneeAddressId = 1; SELECT * F ...
- IDEA 13》》》14破解
更新IDEA 15注册方式 http://15.idea.lanyus.com/ ------------------------------------------------ 之前的已不能用,下面 ...
- .net excel利用NPOI导入oracle
1.链接数据库 引用System.Data.OracleClient: //数据库链接字符串 Data Source如:192.168.5.153:1521/orcl string linkStr ...
- node http.request请求
var http = require('http'); var querystring = require('querystring'); var path = '/cricket/getRecord ...
- 对 const char* const &a 的理解
定义中用到&是独立引用. 比如: char i; char &a=i; 表示a是i的一个单独引用. 当有i='a'时,也有a='a'; 当有a='c'时,也有i='c'; 两个变量的标 ...