The Grille

题目链接:

http://acm.hust.edu.cn/vjudge/problem/26634

Description


http://7xjob4.com1.z0.glb.clouddn.com/a7d33cb3303ea18c9e6f3de676f242a6

Input


The input contains several test cases. Each test case contains description of a grille and a ciphertext.
Your task is to decipher the message and write the plaintext to output.
Each test case starts with a line containing number N (1 ≤ N ≤ 1000), where N is the size of the
grille. Then there are N lines containing the grille description. Each of those lines contains exactly N
characters which are either the “hash” character ‘#’ (solid/opaque material) or the uppercase letter ‘O’
(hole).
Note: In praxis, the grille holes would be arranged in such a way that no position of the ciphertext
is used more than once. In our problem, this is not guaranteed. Some grilles may contain holes that
match the same position/letter of the ciphertext (after rotations). However, the deciphering algorithm
is still the same.
After the grille description, there are another N lines with the enciphered message. Each of them
contains exactly N characters - uppercase letters of alphabet.
The last test case is followed by a line containing one zero.

Output


For each test case, output the deciphered message (plaintext) on one line with no spaces.

Sample Input


```
4
##O#
#O#O
####
###O
ARAO
PCEM
LEEN
TURC
3
O#O
###
O#O
ABC
DEF
GHI
0
```

Sample Output


ACMCENTRALEUROPE
ACGIACGIACGIACGI

Source


2016-HUST-线下组队赛-1


##题意:

加密过程:每次在空白位置写一个字符,写完后正旋90°再写,重复四次.
求解密后的字符串.


##题解:

瞎转一通就好了.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 1010
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

int n;

char mes[maxn][maxn];

char key[maxn][maxn];

char ans[maxnmaxn4];

int main(int argc, char const *argv[])

{

//IN;

while(scanf("%d", &n) != EOF && n)
{
for(int i=1; i<=n; i++) {
scanf("%s", key[i]+1);
}
for(int i=1; i<=n; i++) {
scanf("%s", mes[i]+1);
} int cnt = 0;
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) if(key[i][j] == 'O') {
ans[cnt++] = mes[i][j];
}
} for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) if(key[n-j+1][i] == 'O') {
ans[cnt++] = mes[i][j];
}
} for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) if(key[n-i+1][n-j+1] == 'O') {
ans[cnt++] = mes[i][j];
}
} for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) if(key[j][n-i+1] == 'O') {
ans[cnt++] = mes[i][j];
}
} ans[cnt] = 0;
printf("%s\n", ans);
} return 0;

}

UVALive 5886 The Grille (模拟)的更多相关文章

  1. UVALive - 6269 Digital Clock 模拟

    UVALive - 6269 Digital Clock 题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少. 思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打 ...

  2. UVALive - 7139(差分+模拟)

    题目链接 参考 题意 N*M的网格,一辆车沿着网格线按给定路线走,每个网格里有一个人,人的视线始终看着车,问这些人净转圈数的平方和. 分析 由于车的起点和终点都为左上角,且每个格子里的人永远面对着车, ...

  3. UVALive 7464 Robots(模拟)

    7464Robots Write a program to collect data from robots. We are given two sets of robotsX=fX1;:::;Xmg ...

  4. 【Bit String Reordering UVALive - 6832 】【模拟】

    题意分析 题目讲的主要是给你一个01串,然后给你要变成的01串格式,问你要转换成这一格式最少需要移动的步数. 题目不难,但当时并没有AC,3个小时的个人赛1道没AC,归根到底是没有逼自己去想,又想的太 ...

  5. 【Miscalculation UVALive - 6833 】【模拟】

    题目分析 题目讲的是给你一个串,里面是加法.乘法混合运算(个人赛中误看成是加减乘除混合运算),有两种算法,一种是乘法优先运算,另一种是依次从左向右运算(不管它是否乘在前还是加在前). 个人赛中试着模拟 ...

  6. UVaLive 6809 Spokes Wheel (模拟)

    题意:给定两个16进制数,问你把它转成二进制后,把第一个向左或者向右旋转最少的次数同,使得第一个变成第二个. 析:也是比较水的,按照要求做就好,注意0的情况,可能会忘记. #pragma commen ...

  7. UVALive 6858 Frame (模拟)

    Frame 题目链接: http://acm.hust.edu.cn/vjudge/contest/130303#problem/D Description http://7xjob4.com1.z0 ...

  8. 【模拟】ECNA 2015 I What's on the Grille? (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: 栅栏密码.给定N(N<=10),密钥为一个N*N的矩阵,'.'代表空格可以看到,'X'代表被遮挡,还有密 ...

  9. 模拟/字符串处理 UVALive 6833 Miscalculatio

    题目传送门 /* 模拟/字符串处理:主要是对*的处理,先把乘的预处理后再用加法,比如说是:1+2*3+4 = 1+..6+4 = 11 */ #include <cstdio> #incl ...

随机推荐

  1. POJ 3468 (线段树 区间增减) A Simple Problem with Integers

    这题WA了好久,一直以为是lld和I64d的问题,后来发现是自己的pushdown函数写错了,说到底还是因为自己对线段树理解得不好. 因为是懒惰标记,所以只有在区间分开的时候才会将标记往下传递.更新和 ...

  2. svn备份脚 本

    一直用这套脚本备份,脚本主体虽不是原创,但是从网上得到后因为不能运行也进行了些修改,前两天看到有人问关于SVN备份的问题,今天又把脚本整理了一下,解决了不能循环备份多个配置库的问题.希望对大家有所帮助 ...

  3. C语言之字节对齐

    在C语言编程中,有时为了达到减少运行的时间的目的,需要浪费一些空间:而有时为了节省空间,使它的运行时间增长.而字节对齐则是为了访问效率,用空间换取时间. 要掌握字节对齐,首先得明确一下四个概念: 1. ...

  4. gcc g++ 参数介绍

    C和C++ 编译器是集成的.他们都要用四个步骤中的一个或多个处理输入文件: 预处理 (preprocessing),编译(compilation),汇编(assembly)和连接(linking).源 ...

  5. 旧书重温:0day2【1】 简单的缓冲区溢出案例

    0x01 准备: VMwarePlayer (我是在360软件管家那搜到的下载的) xp sp2 http://user.qzone.qq.com/252738331/blog/1357138598 ...

  6. 【Python】菜鸟的基本课程继续中

    同样的缩进表示这段代码处于同一个层次. 每一个print都自带一个换行. 定义变量一定要在使用函数等之前. abs(-14) ======= 取绝对值函数 内建函数 print abs(-14) == ...

  7. Python网页解析

    续上篇文章,网页抓取到手之后就是解析网页了. 在Python中解析网页的库不少,我最开始使用的是BeautifulSoup,貌似这个也是Python中最知名的HTML解析库.它主要的特点就是容错性很好 ...

  8. 安卓 Pickers(选择器)

    概述 安卓提供了现成的对话框,让用户选择一个时间或日期.每一个选择器控制时间(小时,分钟,AM/PM)或日期(月,日,年)的每一部分的选择.使用这些选择器帮助 确保用户正确的,格式化的,和适合的选择一 ...

  9. 学好Javascript是有方法的

    先声明下噢,这篇文章不是自个儿写的,看着好,希望前端小孩们可以和我一起加油,大家都来借鉴借鉴吧- 首先要说明的是,咱现在不是高手,最多还是一个半桶水,算是入了JS的门. 谈不上经验,都是一些教训. 这 ...

  10. 【转】IOS 开发环境,证书和授权文件等详解

    (转自:http://blog.csdn.net/gtncwy/article/details/8617788) 一.成员介绍1.    Certification(证书)证书是对电脑开发资格的认证, ...