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 ...
随机推荐
- 【问题解决方案】GitHub的md中使用库中图片
参考链接: 在GitHub中使用图片功能 步骤: 在github上的仓库建立一个存放图片的文件夹,文件夹名字随意.如:image 将需要在插入到文本中的图片,push到image文件夹中. 然后打开g ...
- linux性能相关的各个环节
- Django 使用简单笔记
1. Django项目的启动: 1. 命令行启动 在项目的根目录下(也就是有manage.py的那个目录),运行: python3 manage.py runserver IP:端口--> 在指 ...
- bzoj2669 [cqoi2012]局部极小值 状压DP+容斥
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2669 题解 可以发现一个 \(4\times 7\) 的矩阵中,有局部最小值的点最多有 \(2 ...
- MVC模式设计的Web层框架初识
struts是个什么东西? struts是一个按MVC模式设计的Web层框架,其实它就是一个大大的servlet,这个Servlet名为ActionServlet,或是ActionServlet的子类 ...
- Cesium标点
let startPoint = this.viewer.entities.add( //viewer.entities.add 添加实体的方法 { name: '测量距离', //这个属性跟页面显示 ...
- centos 6.5 配置阿里云 yum 镜像
配置国内镜像目的是为了加速软件下载安装速度,参考链接:http://mirrors.aliyun.com/help/centos 备份.养成文件操作前备份的习惯 cd /etc/yum.repos.d ...
- Halo(八)
安全模块 用户描述类 /** * 基本 Entity */ @Data @MappedSuperclass public class BaseEntity { /** Create time */ @ ...
- 如何通过Dataphin构建数据中台新增100万用户?
欢迎来到数据中台小讲堂!这一期我们来看看,作为阿里巴巴数据中台(OneData - OneModel.OneID.OneService)方法论的产品载体,Dataphin如何帮助传统零售企业实现数字化 ...
- ES6中类Class的super关键字
super 关键字,既可以当作函数使用,也可以当作对象使用.在这两种情况下,它的用法完全不同. 1.super当做函数使用 super 作为函数调用时,代表父类的构造函数.ES6 要求,子类的构造函数 ...