Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力
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 暴力的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 2010 NEERC Western subregional
2010 NEERC Western subregional Problem A. Area and Circumference 题目描述:给定平面上的\(n\)个矩形,求出面积与周长比的最大值. s ...
- 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 ...
- 【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest
A-Area and Circumference 题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值. #include <iostream> #include <algo ...
随机推荐
- 《高性能MySQL》——第一章MySQL的架构与历史
1.可以使用SHOW TABLE STATUS查询表的相关信息. 2.默认存储引擎是InnoDB,如果没有什么很特殊的要求,InnoDB引擎是我们最好的选择. 3.mysql的infobright引擎 ...
- html5 canvas从圆开始
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- expect 交互
expect expect 是一种自动交互语言,能实现在shell脚本中为scp和ssh等自动输入密码自动登录. exp_continue # 多个spawn命令时并行 interact # 执行完成 ...
- list(列表)操作【五】
L表示从左边(头部)开始插与弹出,R表示从右边(尾部)开始插与弹出. 一.概述: 在Redis中,List类型是按照插入顺序排序的字符串链表.和数据结构中的普通链表一样,我们可以在其头部(l ...
- ESXi 6.5 总是会话超时
ESXi 6.5 客户端Web界面会话超时 在VMware ESXi 6.5中,主机客户端Web界面会话每15分钟自动超时一次,然后您必须再次重新登录ESXi主机客户端Web界面. 要避免这种繁琐的情 ...
- 谁在call我-backtrace的实现原理【转】
转自:http://www.xuebuyuan.com/1504689.html 显示函数调用关系(backtrace/callstack)是调试器必备的功能之一,比如在gdb里,用bt命令就可以查看 ...
- Linux字符集的查看及修改【转】
一·查看字符集字符集在系统中体现形式是一个环境变量,以CentOS6.5为例,其查看当前终端使用字符集的方式可以有以下几种方式: 1.[root@david ~]# echo $LANGzh_CN.G ...
- 使用eclipse构建Maven项目及发布一个Maven项目
开发环境: Eclipse Jee Mars(截止2015年12月1日目前的最新版eclipse4.5),下载地址:http://www.eclipse.org/downloads/ 因为此版本已经集 ...
- Fiddler实现移动端手机抓包
Fiddler是一个http调试代理,它能 够记录所有的你电脑和互联网之间的http通讯,Fiddler 可以也可以让你检查所有的http通讯,设置断点,以及Fiddle 所有的“进出”的数据(指co ...
- ubuntu16。04LST配置nfs实现服务器和客户端共享文件
NFS(network file system)网络文件系统可以实现不同主机与操作系统之间通过网络进行资源共享,此时一台PC充当服务器,若干台PC充当那客户端,具体如何配置请跟随我的步骤来做 1 下载 ...