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°再写,重复四次.
求解密后的字符串.
##题解:
瞎转一通就好了.
##代码:
``` 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 (模拟)的更多相关文章
- UVALive - 6269 Digital Clock 模拟
UVALive - 6269 Digital Clock 题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少. 思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打 ...
- UVALive - 7139(差分+模拟)
题目链接 参考 题意 N*M的网格,一辆车沿着网格线按给定路线走,每个网格里有一个人,人的视线始终看着车,问这些人净转圈数的平方和. 分析 由于车的起点和终点都为左上角,且每个格子里的人永远面对着车, ...
- UVALive 7464 Robots(模拟)
7464Robots Write a program to collect data from robots. We are given two sets of robotsX=fX1;:::;Xmg ...
- 【Bit String Reordering UVALive - 6832 】【模拟】
题意分析 题目讲的主要是给你一个01串,然后给你要变成的01串格式,问你要转换成这一格式最少需要移动的步数. 题目不难,但当时并没有AC,3个小时的个人赛1道没AC,归根到底是没有逼自己去想,又想的太 ...
- 【Miscalculation UVALive - 6833 】【模拟】
题目分析 题目讲的是给你一个串,里面是加法.乘法混合运算(个人赛中误看成是加减乘除混合运算),有两种算法,一种是乘法优先运算,另一种是依次从左向右运算(不管它是否乘在前还是加在前). 个人赛中试着模拟 ...
- UVaLive 6809 Spokes Wheel (模拟)
题意:给定两个16进制数,问你把它转成二进制后,把第一个向左或者向右旋转最少的次数同,使得第一个变成第二个. 析:也是比较水的,按照要求做就好,注意0的情况,可能会忘记. #pragma commen ...
- UVALive 6858 Frame (模拟)
Frame 题目链接: http://acm.hust.edu.cn/vjudge/contest/130303#problem/D Description http://7xjob4.com1.z0 ...
- 【模拟】ECNA 2015 I What's on the Grille? (Codeforces GYM 100825)
题目链接: http://codeforces.com/gym/100825 题目大意: 栅栏密码.给定N(N<=10),密钥为一个N*N的矩阵,'.'代表空格可以看到,'X'代表被遮挡,还有密 ...
- 模拟/字符串处理 UVALive 6833 Miscalculatio
题目传送门 /* 模拟/字符串处理:主要是对*的处理,先把乘的预处理后再用加法,比如说是:1+2*3+4 = 1+..6+4 = 11 */ #include <cstdio> #incl ...
随机推荐
- 推荐 10 款最好的 Python IDE
简述 Python 非常易学,强大的编程语言.Python 包括高效高级的数据结构,提供简单且高效的面向对象编程. Python 的学习过程少不了 IDE 或者代码编辑器,或者集成的开发编辑器(IDE ...
- Qt之模型/视图(自定义进度条)
简述 在之前的章节中分享过关于QHeaderView表头排序.添加复选框等内容,相信大家模型/视图.自定义风格有了一定的了解,下面我们来分享一个更常用的内容-自定义进度条. 实现方式: 从QAbstr ...
- UVa 12174 (滑动窗口) Shuffle
首先预处理一下以每个数为结尾的前s个数是否能构成一个1~s的排列. 可以用cnt数组来记录每个数出现的次数和用一个变量记录一共有多少个不同的数出现. 然后枚举每种可能的情况,也就是枚举第一首歌会出现的 ...
- sql DROP 和DELETE、TRUNCATE用法
DROP:删除数据库已存在的表DROP TABLE tbname DELETE:删除记录delete from tbname truncate:清空表,重置索引truncate table tbnam ...
- Sqlite数据库 找不到请求的 .Net Framework Data Provider。可能没有安装
解决方法 在web.config里面添加 <system.data> <DbProviderFactories> <remove invariant="Sy ...
- 用AngularJS开发的过程中如何查看Scope内容
scope的继承就好比JS的原型链继承,深入理解Scope:http://www.lovelucy.info/understanding-scopes-in-angularjs.html 通过查看官网 ...
- 快速查询Python脚本语法
/********************************************************************* * 快速查询Python脚本语法 * 说明: * Char ...
- ecshop 在首页每个商品下显示已销售数量
1.在includes/lib_goods.php文件末尾加入以下代码 function get_buy_sum($goods_id) { $sql = "select sum(goods_ ...
- php 使用date()函数的报错
错误提示: Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* ...
- JQuery Mobile实现手机新闻浏览器(2)
在上一篇文章中,已经讨论了程序的结构和页面的布局,并简单介绍了一些jQuery Mobile的使用技巧.在本篇文章中,笔者将继续完成我们web应用的新闻浏览器的设计. 程序的启动 我们现在来研究一下程 ...