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 ...
随机推荐
- UVALive 2218 Triathlon
https://vjudge.net/problem/UVALive-2218 题意: 铁人三项比赛,每项比赛长度未定,已知每个选手每项比赛的平均速度. 设计每项比赛的长度,让其中某个特定选手获胜. ...
- python学习笔记6--mockserver
一.mockserver的应用 有时候测试我们需要调用一些三方接口或者未开发完成的接口,完成我们的业务流程测试,但是这时候可能我们只知道接口返回值,接口并没有完全开发完成或可以让我们任意调用,这时候就 ...
- [整理]C 内核源代码-学习资料
GNU C gnu项目:http://www.gnu.org/software/software.html ftp:http://ftp.gnu.org/gnu/ 托管:http://savannah ...
- Linux学习6-套接字
套接字 1.什么是套接字? 套接字(socket)是一种通信机制,凭借这种机制,客户/服务器系统的开发工作既可以在本地单机上进行,也可以跨网络进行. 2.套接字应用程序是如何通过套接字来维持一个连接的 ...
- auto
把左和右外边距设置为 auto,规定的是均等地分配可用的外边距.结果就是居中的元素: <style> .centerrr { margin:auto; width:70%; backgro ...
- HDU 4712 Hamming Distance(随机算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4712 解题报告:输入n个数,用十六进制的方式输入的,任意选择其中的两个数进行异或,求异或后的数用二进制 ...
- requests(一): 发送一个json格式的post请求
今天给一位同学解决post发送数据格式为json格式的请求,顺便确认一下问题归属. 背景: 用postman工具发送一个数据格式为json的请求,得到了服务器的响应. 用python的requests ...
- MySQL常见的两种存储引擎:MyISAM与InnoDB的爱恨情仇
Java面试通关手册(Java学习指南,欢迎Star,会一直完善下去,欢迎建议和指导):https://github.com/Snailclimb/Java_Guide 一 MyISAM 1.1 My ...
- Windows 8.1/10配置VS 2013 + MPI开发环境
关于win上安装MPI开发环境,网上能搜到的教程貌似都很老,还需要在管理员账户开发,感觉很诡异,于是自己摸索了下,不需要管理员账户,总结如下. 1. 准备 VS 2013(VS 2010及以上都行) ...
- Nginx安装方式探究
Ubuntu 16.04(阿里云ECS),Nginx 1.10.3 (Ubuntu) 本文探究两种安装方式: 1.源码安装(手动) 2.APT安装(自动) 源码安装(手动) 步骤简介: 下载.解压.. ...