Problem F. Turning Grille

题目连接:

http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&all_runs=1&action=140

Description

‘Turning grille’ method is one of the simplest forms of transposition cipher. A variant of this method is

as follows. The sender of the message writes it onto a square sheet of paper gridded into N rows and

N columns, one character per cell. The number N is even. A grille is used for ciphering—a pierced sheet

of cardboard of the same size as the paper. There are N2/4 holes made in the grille, and one cell can be

seen through each hole. When writing a message, the grille is placed on a sheet of paper, and the letters

of the message are written into the holes from top to bottom. After all holes have been filled, the grille

is turned 90◦

clockwise, and the writing goes on. The grille can be turned three times, and the message

length does not exceed N2

.

The receiver of the message has the same grille and, performing the same manipulations, reads the

characters that appear in the holes.

A well-formed grille must not show the same paper sheet cell several times during grille rotations. However,

the holes are manufactured by hand and a master can make mistakes, especially when creating a big

grille. . .

Write a program that checks if a grille is correct.

Input

The first line of input contains the integer N, the size of the paper (4 ≤ N ≤ 1000, N is even). N lines

follow, each corresponds to a row of the grille and contains N characters . (no hole) or * (a hole). The

number of holes is N2/4.

Output

Output the line YES or NO depending on whether the grille is well-formed or not.

Sample Input

4

...

..
*

....

.*..

Sample Output

YES

Hint

题意

给你一个解密卡,就是那个*就是洞洞,然后转90°,转四次,问你洞洞能不能覆盖所有点。

保证解密卡有n^2/4个洞洞。

题解:

哈哈,我说这个就是像小时候玩过的冒险小虎队的那个解密卡。

这个xjb搞一搞就好了

代码

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 15;
int N ;
char str[4][maxn][maxn]; int main(int argc, char * argv[]){
// freopen("in.txt","r",stdin);
scanf("%d",&N);
for(int i = 0 ; i < N ; ++ i){
scanf("%s" , str[0][i]);
}
for(int i = 1 ; i < 4 ; ++ i) for(int j = 0 ; j < N ; ++ j) for(int k = 0 ; k < N ; ++ k) str[i][j][k] = str[i - 1][k][N-j-1];
/* for(int i = 0 ; i < 4 ; ++ i){
for(int j = 0 ; j < N ; ++ j) cout << str[i][j] << endl;
cout << endl;
}*/
vector < pair < int , int > > vi;
for(int i = 0 ; i < 4 ; ++ i)
for(int j = 0 ; j < N ; ++ j)
for(int k = 0 ; k < N ; ++ k)
if( str[i][j][k] == '*' )
vi.push_back( make_pair( j , k ) );
sort( vi.begin() , vi.end() );
assert( vi.size() == N * N );
int C = unique( vi.begin() , vi.end() ) - vi.begin();
if( C == N * N ) printf("YES\n");
else printf("NO\n");
return 0;
}

Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力的更多相关文章

  1. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem C. Cargo Transportation 暴力

    Problem C. Cargo Transportation 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed ...

  2. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题

    Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...

  3. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem I. Alien Rectangles 数学

    Problem I. Alien Rectangles 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c ...

  4. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem H. Parallel Worlds 计算几何

    Problem H. Parallel Worlds 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7 ...

  5. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem G. k-palindrome dp

    Problem G. k-palindrome 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022 ...

  6. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem A. A + B

    Problem A. A + B 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&al ...

  7. 2010 NEERC Western subregional

    2010 NEERC Western subregional Problem A. Area and Circumference 题目描述:给定平面上的\(n\)个矩形,求出面积与周长比的最大值. s ...

  8. 2009-2010 ACM-ICPC, NEERC, Western Subregional Contest

    2009-2010 ACM-ICPC, NEERC, Western Subregional Contest 排名 A B C D E F G H I J K L X 1 0 1 1 1 0 1 X ...

  9. 【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest

    A-Area and Circumference 题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值. #include <iostream> #include <algo ...

随机推荐

  1. H5 Day1 练习

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. argunlar 1.0.1 【数据绑定】

    <!DOCTYPE html><html lang="en" ng-app><head>    <meta charset="U ...

  3. JavaScript编写风格指南 (三)

    七(七):严格模式 // 严格模式应当仅限在函数内部使用,千万不要在全局使用 //不好的写法:全局使用严格模式"user strict"; function doSomething ...

  4. UI渲染回顾简单笔记

    UI渲染的简单过程: CPU,GPU,显示器协同工作,CPU 中计算显示内容,比如视图的创建.布局计算.图片解码.文本绘制等,然后将计算结果提交给GPU,由 GPU 进行变换.合成.渲染.随后 GPU ...

  5. Linux - awk 文本处理工具三

    AWK 文件打印匹配 格式示例 awk '/Tom/' file # 打印匹配到得行 awk '/^Tom/{print $1}' # 匹配Tom开头的行 打印第一个字段 awk '$1 !~ /ly ...

  6. C++--------------------------------指针和数组替换使用原因

    马上要考试了,复习数据结构中,对C的指针不太了解,在严蔚敏<数据结构(C语言版)>中,发现p22定义顺序存储结构: typedef srtuct{ ElemType *elem; //存储 ...

  7. 高可用的并行MySQL数据同步及分布式

    首先聊聊MySQL的数据分布式,目前最为常用的就是Replication(复制)技术.基于此技术外延开来有很多中架构,分类归结为如下:      1.树状结构(Master,Backup-Master ...

  8. JavaScript:document.execCommand()的用法

    document.execCommand()的用法小记 一.语法 execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令.处理Html数据时常用. 如下格式:document.ex ...

  9. 阿里云服务器配置nginx和PHP

    1. 安装及启动nginx 输入yum install nginx命令进行nginx的安装,当需要确认时输入”y“确认. yum install nginx 安装完成后,输入service nginx ...

  10. web html调用百度地图

    如果想在自己的网页上面加入百度地图的话,可以用百度地图的api.具体使用方法如下: 第一步:进入百度创建地图的网站http://api.map.baidu.com/lbsapi/creatmap/,搜 ...