UVALive 5886 The Grille (模拟)

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°再写,重复四次.
求解密后的字符串.


题解:


瞎转一通就好了.


代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <list>
#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[maxn*maxn*4];

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;
}

转载于:https://www.cnblogs.com/Sunshine-tcf/p/5791334.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值