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. Python配置tab自动补全功能

    # cat tab.py #!/usr/bin/python # python tab file import sys import readline import rlcompleter impor ...

  2. Does Deep Learning Come from the Devil?

    Does Deep Learning Come from the Devil? Deep learning has revolutionized computer vision and natural ...

  3. python 通用字典方法

    版本1 方法 # 不传返回所有属性,传入props只返回传入的对应属性 def m_dict(obj, props=[]): result = {} target = obj else props f ...

  4. ASP.NET MVC学习(二)之控制器Controller

    1.控制器 Controller接收用户请求,将Model和View匹配在一起,共同完成用户请求.它是一个分发器,通过选择不同的Model.View,可以决定完成不同的用户请求. 但Controlle ...

  5. 20155212 2016-2017-2 《Java程序设计》第8周学习总结

    20155212 2016-2017-2 <Java程序设计>第8周学习总结 教材学习内容总结 Chapter14 1. Channel架构与操作 想要取得Channel的实作对象,可以使 ...

  6. svn使用笔记

    一.checkout:第一次下载trunk里面的代码到本地 二.commit:提交一些修改* out of date : 本地版本号 < 服务器版本号* 如果过期,就update,可能会出现co ...

  7. LCT摘要

    介绍.用途 LCT是树链剖分中的一种,又叫实链剖分.动态树,常用于维护动态的树.森林. 维护方式 LCT并不直接维护原树,而是用一堆splay作为辅助树来维护.原树中的一条实链上的点在一棵splay中 ...

  8. springboot中url地址重写(urlwrite)

    在日常网站访问中,会把动态地址改造成伪静态地址. 例如: 访问新闻栏目 /col/1/,这是原有地址,如果这样访问,不利于搜索引擎检索收录,同时安全性也不是很好. 改造之后: /col/1.html. ...

  9. Android Camera详解

    相关的类 android.hardware.camera2 Camera SurfaceView---这个类用于向用户呈现实时相机预览. MediaRecorder---这个类用于从摄像机录制视频. ...

  10. Laravel 自定义创建时间、更新时间字段

    Model 中,如果启动了 timestamps public $timestamps = true; 默认,laravel 会操作对应数据表的 created_at, updated_at 字段. ...