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. Qt之QTableView显示富文本

    简述 对于QTableView中的显示,我们前面介绍过很多种,其中包括:文本.进度条.复选框等,今天我们介绍一下关于富文本的显示. 可能绝大多数小伙伴会通过QAbstractTableModel中的d ...

  2. UVa 1586 Molar mass

    题意:给出物质的分子式,计算它的相对原子质量 因为原子的个数是在2到99之间的,所以找出一个是字母之后,再判断一下它的后两位就可以找出这种原子的个数了 #include<iostream> ...

  3. 在 VC6 中使用 GdiPlus-使用

    下面用 VC6 来写一个 GdiPlus 的 Demo 工程 Step1:新建一个名为 Demo_GdiPlus 的 MFC AppWizard(exe) 工程 操作步骤:(1)主菜单File-> ...

  4. USACO全部测试数据

    链接:http://share.weiyun.com/8c37d26066ee9e63147d2af983f24290 密码:YyGL 请使用2345好压解压.

  5. android linux shell 日期设置

    /************************************************************************ android linux shell 日期设置 * ...

  6. activiti参考5-任务TASK

    一.概要 1,设计TASK的表主要是:ACT_RU_TASK,ACT_HI_TASKINST(见参考-activiti表): 2,任务主要有:人工任务(usertask),服务任务(serviceta ...

  7. Mac Maven java_home错误

    当maven装好之后出现 $ mvn -versionError: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec ...

  8. php的webservice的soapheader认证问题

    参数通过类传输:class authentication_header {       private $username;       private $password;       public ...

  9. Filling a Path 模式

    Filling a Path When you fill the current path, Quartz acts as if each subpath contained in the path ...

  10. Java自动装箱拆箱

    一.装箱.拆箱定义 如果一个int型量被传递到需要一个Integer对象的地方,那么,编译器将在幕后插入一个对Integer构造方法的调用,这就叫做自动装箱.而如果一个Integer对象被放到需要in ...