Steganography is one of the most famous techniques for hiding information in different places, including images. Recently, for example, Xerox announced they were releasing a 2D-hieroglyphs that were able to codify a message within them. Your task is to decipher a 2D-hieroglyph.
A 2D hieroglyph is a matrix H of 10 rows and M + 2 columns that encode a message of length M characters (c0, c1, . . . , cM−1). The matrix H has the following lattice:
where
and c is the ASCII value of the character passed to the b function.
Your task is to find the message given the matrix H.
Input
The input is composed of a first line with a number N indicating the number of messages to decode, followed by N matrices separated by a “newline” character. The length of any message will not be more than 80 characters.
Output
The output must have N messages, one per each matrix given in the input.
Sample Input
2
///
//\///\\///\/
///
///\\///\//\/\\//\//
///\/\\//
//\/
/
/\/\\\/\/\\\/\/\/\\\\/
///
///
///
//
//\//\///
\\///
\/
///
/\\\\/
/\\\\/
///
///
Sample Output
LA LLUVIA EN SEVILLA ES UNA MARAVILLA
abcdefghi
问题链接:UVA10851 2D Hieroglyphs decoder
问题简述:(略)
问题分析:
。
。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA10851 2D Hieroglyphs decoder */
#include <bits/stdc++.h>
using namespace std;
int convert[]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
const int H = 10;
const int L = 80;
char b[H][L + 1];
char mychar(int k, char c)
{
return c / convert[k] % 2 ? 92 : 47;
}
int main()
{
int t;
scanf("%d", &t);
while(t--) {
getchar();
for(int i = 0; i < H; i++)
gets(b[i]);
int end = strlen(b[0]) - 2;
for(int i = 1; i <= end; i++) {
for(char c = ' '; c <= 'z'; c++) {
bool flag = true;
for(int j = 1; j <= H - 2; j++)
if(mychar(j - 1, c) != b[j][i]) {
flag = false;
break;
}
if(flag) {
putchar(c);
break;
}
}
}
putchar('\n');
}
return 0;
}