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 ...
随机推荐
- windows下nvm的安装及使用
由于更新了npm版本之后导致npm的命令都会报错,一顿百度,明白了nvm可以管理node版本的,下面是操作过程: 如果在安装nvm之前已经下载了node 需要把node卸载!!! 需要把node卸载! ...
- 创建一个java项目并部署到weblogic服务器
转自:https://blog.csdn.net/krystal_sl/article/details/52847953 新建一个项目的步骤 打开eclipse,右键点击new–>java pr ...
- 自定义的最简单的可回调的线程任务CallbackableFeatureTask(模仿google的ListenableFutureTask)
1.使该Task继承Callable,Runable import java.util.concurrent.Callable; import java.util.function.Consumer; ...
- read - 在文件描述符上执行读操作
概述#include <unistd.h> ssize_t read(int fd, void *buf, size_t count); 描述read() 从文件描述符 fd 中读取 co ...
- Tomcat-部署多个项目(不同端口)
20190713 整理 参考文档 https://blog.csdn.net/chenchunlin526/article/details/78799772 如何在Tomcat服务中,为不同端口部署 ...
- "Unable to locate package lrzsz"的解决办法
某天安装一些常用软件,比如lrzsz的时候出错了 $ sudo apt-get install lrzsz Reading package lists... Done Building depende ...
- 同步mysql
ElasticSearch同步MySql 标签: elasticsearchmysql 2016-07-01 09:07 4636人阅读 评论(8) 收藏 举报 分类: Elasticsearch( ...
- ERROR=(CODE=1153)
jdbc 连接oracle数据库(10.2.0.4),应用程序报错如下: Connection refused(DESCRIPTION=(ERR=1153)(VSNNUM=169870592)(ERR ...
- 谷歌开发人员在现代Web浏览器中发现严重跨域漏洞
Google谷歌研究人员在现代网络浏览器中发现了一个严重漏洞,该漏洞可能允许您访问的网站从您登录同一浏览器的其他网站窃取您的在线帐户的敏感内容. 由Google谷歌Chrome的开发者支持者Jake发 ...
- python request 接口测试get和post请求
开发IDE:pycharm python:2.7.10 get请求 # coding: UTF-8 #兼容中文字符,如果没有这句,程序中有中文字符时,运行会报错 import requests #引用 ...