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搞一搞就好了

代码

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int maxn = 1e3 + 15;
  4. int N ;
  5. char str[4][maxn][maxn];
  6. int main(int argc, char * argv[]){
  7. // freopen("in.txt","r",stdin);
  8. scanf("%d",&N);
  9. for(int i = 0 ; i < N ; ++ i){
  10. scanf("%s" , str[0][i]);
  11. }
  12. 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];
  13. /* for(int i = 0 ; i < 4 ; ++ i){
  14. for(int j = 0 ; j < N ; ++ j) cout << str[i][j] << endl;
  15. cout << endl;
  16. }*/
  17. vector < pair < int , int > > vi;
  18. for(int i = 0 ; i < 4 ; ++ i)
  19. for(int j = 0 ; j < N ; ++ j)
  20. for(int k = 0 ; k < N ; ++ k)
  21. if( str[i][j][k] == '*' )
  22. vi.push_back( make_pair( j , k ) );
  23. sort( vi.begin() , vi.end() );
  24. assert( vi.size() == N * N );
  25. int C = unique( vi.begin() , vi.end() ) - vi.begin();
  26. if( C == N * N ) printf("YES\n");
  27. else printf("NO\n");
  28. return 0;
  29. }

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. bzoj千题计划190:bzoj4300: 绝世好题

    http://www.lydsy.com/JudgeOnline/problem.php?id=4300 f[i] 表示第i位&为1的最长长度 #include<cstdio> # ...

  2. 流媒体技术学习笔记之(七)进阶教程OBS参数与清晰度流畅度的关系

    源码地址:https://github.com/Tinywan/PHP_Experience 很多主播问过OBS的参数到底什么影响画质,到底什么影响流畅度,那么本篇教程尽量用通俗的语言解释下一些重要参 ...

  3. ASP.NET MVC学习笔记-----Filter(2)

    接上篇ASP.NET MVC学习笔记-----Filter(1) Action Filter Action Filter可以基于任何目的使用,它需要实现IActionFilter接口: public ...

  4. CentOS 编译 GCC 7.2

    CentOS 编译 GCC 7.2 下载源码 wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-7.2.0/gcc-7.2.0. ...

  5. BZOJ1009 GT考试

    1009: [HNOI2008]GT考试 Time Limit: 1 Sec  Memory Limit: 162 MB Description 阿申准备报名参加GT考试,准考证号为N位数X1X2.. ...

  6. 20155321 2016-2017-2 《Java程序设计》第八周学习总结

    20155321 2016-2017-2 <Java程序设计>第八周学习总结 教材学习内容总结 创建Logger对象 static Logger getLogger(String name ...

  7. leaflet-velocity 参数

    本文地址: https://www.cnblogs.com/veinyin/p/10769611.html  leaflet-velocity 是 leaflet 绘制风场的一个插件,其控制参数如下所 ...

  8. Python super() 函数

    super() 函数是用于调用父类(超类)的一个方法. super 是用来解决多重继承问题的,直接用类名调用父类方法在使用单继承的时候没问题,但是如果重定义某个方法,该方法会覆盖父类的同名方法,但有时 ...

  9. [转]linux各文件夹介绍

    本文来自linux各文件夹的作用的一个精简版,作为个人使用笔记. 下面简单看下linux下的文件结构,看看每个文件夹都是干吗用的? /bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管 ...

  10. C# IEqualityComparer类型参数写法

    最近在使用Union.Except时,由于默认的对比不太好使,所以需要自定义对比器,下面附上代码. class MaterialListComparer : IEqualityComparer< ...