版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/。未经本作者同意不得转载。 https://blog.csdn.net/kenden23/article/details/24574109

Our program committee uses different tools for problem development: a mailing list, a version control system, an administration system of the Timus Online Judge website, and many others. Chairman
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.
Not trusting his memory, the chairman wants to write down one of the passwords in a ciphered form. To do this, he plans to use a cipher grille he read about in one entertaining book.
A cipher grille is a 4 × 4 paper square in which four windows are cut out. Putting the grille on a paper sheet of the same size, the chairman writes down the first four symbols of his password in the
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.
Assume that you obtained the grille used by the chairman and the resulting square with 16 symbols. Your task is to recover the chairman's password.

Input

The first four lines contain the chairman's cipher grille. The window in it is denoted by the symbol “X” and the paper is denoted by “.”. The position of this grille corresponds to the position from
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.
The next four lines contain the square with the ciphered password. All the symbols in the square are lowercase or uppercase Latin letters.

Output

Output the password of the chairman of the program committee as a string consisting of 16 symbols.

Sample

input output
....
X..X
.X..
...X
Pwoo
Khaa
smrs
odbk
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 题解的更多相关文章

  1. Timus : 1002. Phone Numbers 题解

    把电话号码转换成为词典中能够记忆的的单词的组合,找到最短的组合. 我这道题应用到的知识点: 1 Trie数据结构 2 map的应用 3 动态规划法Word Break的知识 4 递归剪枝法 思路: 1 ...

  2. Round 0: Regionals 2010 :: NEERC Eastern Subregional

    Round 0: Regionals 2010 :: NEERC Eastern Subregional 贴吧题解(官方)? 网上的题解 水 A Murphy's Law 题意:Anka拿着一块涂着黄 ...

  3. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  4. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  5. 【题解】[CJOI2019]Cipher

    [题解][CJOI2019]Cipher 题目描述 给定你\(p\)进制数\(s\),\(p \le 9+26\),求对于十进制数\(k\),求\(k^s \equiv ? \mod m\) 数据范围 ...

  6. Timus 2005. Taxi for Programmers 题解

    The clock shows 11:30 PM. The sports programmers of the institute of maths and computer science have ...

  7. BZOJ4653 & 洛谷1712 & UOJ222:[NOI2016]区间——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4653 https://www.luogu.org/problemnew/show/P1712 ht ...

  8. 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 ...

  9. BZOJ 1031: [JSOI2007]字符加密Cipher 后缀数组

    1031: [JSOI2007]字符加密Cipher Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 6014  Solved: 2503[Submit ...

随机推荐

  1. python常用函数 F

    filter(callable, list/tuple) 接收一个函数和一个序列,完成元素过滤. 例子: fnmatch(str,str) 使用底层操作系统的大小写敏感规则来匹配模式. 例子: fnm ...

  2. httpclient get/post请求

    public static String httpPost(String url, JSONObject json) { String respContent = null; try{ HttpPos ...

  3. 第三节 基本数据写入 --------增加&查询

    启动mongodb服务 net start mongodb 链接mongodb  进入bin目录 mongo 127.0.0.1:12345 启动连接 show dbs   显示所有的数据库 use ...

  4. INSTR代替NOT LIKE

    instr(title,'手册')>0  相当于  title like '%手册%' instr(title,'手册')=1  相当于  title like '手册%' instr(titl ...

  5. Spring---条件注解@Conditional

    1.概述 1.1.Spring4  提供了一个更通用的  基于条件的Bean的创建,即使用@Conditional注解: 1.2.案例 package com.an.config; import co ...

  6. docker 运行jenkins及vue项目与springboot项目(三.jenkins的使用及自动打包vue项目)

    docker 运行jenkins及vue项目与springboot项目: 一.安装docker 二.docker运行jenkins为自动打包运行做准备 三.jenkins的使用及自动打包vue项目 四 ...

  7. 【leetcode】1022. Smallest Integer Divisible by K

    题目如下: Given a positive integer K, you need find the smallest positive integer N such that N is divis ...

  8. 【leetcode】609. Find Duplicate File in System

    题目如下: Given a list of directory info including directory path, and all the files with contents in th ...

  9. 查完数据库order_by后跟[:9]切片取前9位的值

  10. linux 下启动tomcat 时没有执行权限

    原因: 没有权限 解决 : chmod 777 *.sh Linux下启动tomcat