Timus 1712. Cipher Grille 题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/。未经本作者同意不得转载。 https://blog.csdn.net/kenden23/article/details/24574109
of the program committee must constantly keep the passwords for these systems in his head. Of course, the passwords must be kept secret from the contestants, otherwise the problems may become known to them before the contest starts.
windows (see fig. below). After that the chairman turns the grille clockwise by 90 degrees. The symbols written earlier become hidden under the grille and clean paper appears in the windows. He writes down the next four symbols of the password in the windows
and again turns the grille by 90 degrees. Then he writes down the following four symbols and turns the grille once more. After that he writes down the last four symbols of the password. Now, without the same cipher grille, it is very difficult to restore the
password from the resulting square with 16 symbols. Thus, the chairman is sure that no contestant will get access to the problems too early.
Input
which the chairman starts writing down his password. It is guaranteed that the grille is correct, which means that in the process of ciphering only empty cells appear in the windows. It is also known that the grille is connected, i.e. it is a single piece
of paper.
Output
Sample
input | output |
---|---|
.... |
KamkohobPassword |
非常有意思的一个加密题目。
加密方法:就是弄一个加密版。然后弄个纸 方块,这个纸方块中间开了特定的4个空,先贴在加密版上,写下4个字母。然后顺时针选择90度,再写下4个字母,继续选择2次,写下16个字母。就是最后的密码了。
如今写个解密算法。
考的知识点就是:旋转数组的问题。
#include <string>
#include <vector>
#include <iostream>
using namespace std;
static const int CI_NUM = 4;
void RotateCipher(vector<string> &cipherGrill)
{
for (int i = 0; i < CI_NUM; i++)
{
for (int j = i, k = CI_NUM - i - 1; k > i; j++, k--)
{
char c = cipherGrill[i][j];
cipherGrill[i][j] = cipherGrill[k][i];
cipherGrill[k][i] = cipherGrill[CI_NUM-i-1][k];
cipherGrill[CI_NUM-i-1][k] = cipherGrill[j][CI_NUM-i-1];
cipherGrill[j][CI_NUM-i-1] = c;
}
}
}
void CipherGrille1712()
{
vector<string> cipherGill(CI_NUM);
vector<string> cipherBoard(CI_NUM);
for (int i = 0; i < CI_NUM; i++)
{
cin>>cipherGill[i];
}
for (int i = 0; i < CI_NUM; i++)
{
cin>>cipherBoard[i];
}
string rs;
for (int d = 0; d < CI_NUM; d++)
{
for (int i = 0; i < CI_NUM; i++)
{
for (int j = 0; j < CI_NUM; j++)
{
if ('X' == cipherGill[i][j]) rs.push_back(cipherBoard[i][j]);
}
}
RotateCipher(cipherGill);
}
cout<<rs;
}
int main()
{
CipherGrille1712();
return 0;
}
Timus 1712. Cipher Grille 题解的更多相关文章
- Timus : 1002. Phone Numbers 题解
把电话号码转换成为词典中能够记忆的的单词的组合,找到最短的组合. 我这道题应用到的知识点: 1 Trie数据结构 2 map的应用 3 动态规划法Word Break的知识 4 递归剪枝法 思路: 1 ...
- Round 0: Regionals 2010 :: NEERC Eastern Subregional
Round 0: Regionals 2010 :: NEERC Eastern Subregional 贴吧题解(官方)? 网上的题解 水 A Murphy's Law 题意:Anka拿着一块涂着黄 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- 【题解】[CJOI2019]Cipher
[题解][CJOI2019]Cipher 题目描述 给定你\(p\)进制数\(s\),\(p \le 9+26\),求对于十进制数\(k\),求\(k^s \equiv ? \mod m\) 数据范围 ...
- Timus 2005. Taxi for Programmers 题解
The clock shows 11:30 PM. The sports programmers of the institute of maths and computer science have ...
- BZOJ4653 & 洛谷1712 & UOJ222:[NOI2016]区间——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=4653 https://www.luogu.org/problemnew/show/P1712 ht ...
- 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=c75360ed7f2c70 ...
- BZOJ 1031: [JSOI2007]字符加密Cipher 后缀数组
1031: [JSOI2007]字符加密Cipher Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 6014 Solved: 2503[Submit ...
随机推荐
- javascript跨浏览器操作xml
//跨浏览器获取xmlDom function getXMLDOM(xmlStr) { var xmlDom = null; if (typeof window.DOMParser != 'undef ...
- smbumount - 为普通用户卸载smb文件系统
总览 smbumount 装载点 描述 普通用户使用这个程序可以卸载smb文件系统.它在工作时会suid到root身份,并且向普通linux用户提供了对资源更多的控制能力.在suid方面,它拥有足够的 ...
- 218- VPX主板 基于5VFX70T的3U VPX 光纤数据采集存储板
基于5VFX70T的3U VPX 光纤数据采集存储板 1.板卡概述 本板卡是基于3U VPX架构,符合VITA46标准,实现了多种图形图像接口的采集与转换.图像数据的处理.宽带数据缓存.SATA存储主 ...
- BJSV-P-004无缝大屏显示
无缝大屏显示 北京太速科技有限公司在线客服:QQ:448468544 淘宝网站:orihard.taobao.com/?联系电话:15084122580 欢迎关注微信公众号 啊智能时代
- Linux数据库还原备份
Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDBHotbackup的一个很好的替代品. https://www.percon ...
- 不在同一个解决方案下的exe去调试dll,采用附加到进程:
先把dll的项目生成一下,把得到的pdb,dll文件复制到exe目录下,然后直接双击运行exe(不是通过vs启动),再接着在dll的项目中”调试”->”附加到进程”,选择刚才运行的exe. 注意 ...
- uCOS的软件定时器、uCOS时钟节拍和滴答定时器的关系
uCOS2.81后的版本中有软件定时器的概念,如果要开启定时器任务,需要在OS_CFG.H文件中 #define OS_TMR_EN 1 软件定时器其实跟硬件中断是相 ...
- JavaSE---锁
1.概述 java中提供了种类丰富的锁, 每种锁因其特性不同,在合适的场景下发挥非常高的效率:
- Ubuntu中可以卸载的软件(持续更新)
sudo apt-get -y --auto-remove purge unity unity-2d* sudo apt-get -y purge empathy sudo apt-get -y pu ...
- Stream学习笔记
1. 创建Stream实例的五种方式 @Test public void test1(){ // 创建Stream对象的第一种方式 List<String> list = Lists.ne ...