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 ...
随机推荐
- 【问题解决方案】在Markdown中生成可以跳转到正文的目录的方法
背景: 一篇博文比较长时,有目录会更方便更一目了然 这里介绍一下使用生成跳转目录的格式 注:GFM即github flavoured markdown 格式 <!-- GFM-TOC --> ...
- 【问题解决方案】git中的文件的重命名
环境: win7 git bash+GitHub 问题: 如果直接在文件夹中手动重命名,Git会判定为删除了旧文件,添加了新文件 版本回退后使用mv命令进行重命名 $ git reset --hard ...
- 20191107PHP创建数组练习
数组练习 <?php //创建的方式 //1 $arr=array(20,30,50); $arr1=[30,60,70]; //3 //当遇到这种情况的时候键(key)是相同的,会取后面的赋值 ...
- 2019-9-2-win10-uwp-打电话
title author date CreateTime categories win10 uwp 打电话 lindexi 2019-09-02 12:57:38 +0800 2018-2-13 17 ...
- React(7) --react父子组件传参
react父子组件传参 父级向子级传参:在父组件中,我们引入子组件,通过给子组件添加属性,来起到传参的作用,子组件可以通过props获取父组件传过来的参数. 在父组件中: import React f ...
- VisualVM监控远程主机
参考博客 https://blog.csdn.net/u010004317/article/details/82948040 https://blog.csdn.net/lienfeng6/artic ...
- Sass--传一个不带值的参数
Sass 的混合宏有一个强大的功能,可以传参,那么在 Sass 中传参主要有以下几种情形: A) 传一个不带值的参数 在混合宏中,可以传一个不带任何值的参数,比如: @mixin border-rad ...
- paper 149:Deep Learning 学习笔记(一)
1. 直接上手篇 台湾李宏毅教授写的,<1天搞懂深度学习> slideshare的链接: http://www.slideshare.net/tw_dsconf/ss-62245351? ...
- CTF | bugku | 字符?正则?
做题链接 一个详细讲正则的网址1 一个详细讲正则的网址2 代码如下 <?php highlight_file('2.php'); $key='KEY{********************** ...
- [CSP-S模拟测试]:旅行(数学+线段树)
题目传送门(内部题12) 输入格式 第一行,一个整数$n$,代表树的点数.第二行,$n$个整数,第$i$个整数是$B_i$,描述排列$B$.接下来$n−1$行,每行两个整数$u,v$,描述一条树边$( ...