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. 转自知乎大神---什么是 JS 原型链?

    我们知道 JS 有对象,比如 var obj = { name: 'obj' } 我们可以对 obj 进行一些操作,包括 「读」属性 「新增」属性 「更新」属性 「删除」属性 下面我们主要来看一下「读 ...

  2. 经典设计模式-iOS的实现

    最近看了<HeadFirst 设计模式>这本书,给组内伙伴准备一次分享,把这次分享记录下来,有需要的可以看看. 这本书主要介绍了四人帮23种经典设计模式中的的14种,也是常用的几种.看完这 ...

  3. HDU 4712 Hamming Distance(随机算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4712 解题报告:输入n个数,用十六进制的方式输入的,任意选择其中的两个数进行异或,求异或后的数用二进制 ...

  4. HDU 4608 I-number 2013 Multi-University Training Contest 1 1009题

    题目大意:输入一个数x,求一个对应的y,这个y满足以下条件,第一,y>x,第二,y 的各位数之和能被10整除,第三,求满足前两个条件的最小的y. 解题报告:一个模拟题,比赛的时候确没过,感觉这题 ...

  5. 记webpack下进行普通模块化开发基础配置(自动打包生成html、多入口多页面)

    写本记时(2018-06-25)的各版本 "webpack": "^4.6.0"  //可直接使用4x以上的开发模式,刷新很快 "webpack-de ...

  6. Java实现去火柴游戏

    package com.gh.p10; /** * Created by Lenovo on 2014/12/10. */ import java.util.Random; import java.u ...

  7. hibernate的一对多和多对一关联

    一对一的关联就不写了,一般项目也用不到,如果可以一对一就直接合成一个表了,也不会出现一对一的关系. 本文主要研究一对多的关系. 1.一对多的关系研究: (1)RDB中关系表达:  多的一方创建外键指向 ...

  8. 全国大学API接口分享

    1.获取省份列表: http://119.29.166.254:9090/api/provinces 返回的是省份列表,其中id很重要. 2.通过省份id查询省份城市: http://119.29.1 ...

  9. QTP图片验证/图片比较/二进制流对比法

    图片验证主要是文件对比,其中我们可以利用二进制的方法读取图片信息,然后进行对比,达到对比的效果,本例子利用fso对象的文件流的方法实现,代码如下: Public Function CompareFil ...

  10. Linux的软中断处理实现 【转】

    转自:http://blog.chinaunix.net/uid-25909619-id-3070190.html 一.概念   首先我们要知道为什么中断需要下半部 .我们可以想象一下,如果没有下半部 ...