UVa10851 - 2D Hieroglyphs decoder(枚举)
来源:互联网 发布:微博淘宝优惠券 编辑:程序博客网 时间:2024/05/29 17:45
The Problem
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 of 10 rows and columns that encode a message of length characters ( ). The matrix has the following lattice:
where
and is the ASCII value of the character passed to the function.
Your task is to find the message given the matrix .
The Input
The input is composed of a first line with a number indicating the number of messages to decode, followed by matrices separated by a "newline" character. The length of any message will not be more than 80 characters.
The Output
The output must have messages, one per each matrix given in the input.
Sample Input
2/////////////////////////////////////////\///\/\\/\//\\/\//\/\\/\/\/\\/\/\//\////////\////\/\/\//////\//\////\/\//////\//\\\\///\\//\\/\\//\//\\//\///\/\\///\//\\//\///\////\\\//////\//\////\\\////////\\//////\/\//////\/\/////\/\////////\//////\//\///////\//\///\///////////\\/\\\\\\/\\/\\\\\\\/\\/\\\/\\\\\\\\\///////////////////////////////////////////////////////////////////////////////////////////\/\/\/\/\///\\//\\///////\\\\///////////\\/////////////\\\\\\\\\//\\\\\\\\\///////////////////////
Sample Output
LA LLUVIA EN SEVILLA ES UNA MARAVILLAabcdefghi
import java.io.FileInputStream;import java.io.BufferedReader;import java.io.BufferedInputStream;import java.io.InputStreamReader;import java.io.StreamTokenizer;import java.io.PrintWriter;import java.io.OutputStreamWriter;import java.util.Scanner;public class Main implements Runnable{private static final boolean DEBUG = false;private static final int ROW = 10;private static final int[] exp = {1, 2, 4, 8, 16, 32, 64, 128};private Scanner cin;private PrintWriter cout;private String[] s;private void init() {try {if (DEBUG) {cin = new Scanner(new BufferedInputStream(new FileInputStream("e:\\uva_in.txt")));} else {cin = new Scanner(new BufferedInputStream(System.in));}cout = new PrintWriter(new OutputStreamWriter(System.out));} catch (Exception e) {e.printStackTrace();}}private void input() {s = new String[ROW];for (int i = 0; i < ROW; i++) {s[i] = cin.next();}}private char check(int col){for (int i = 0; i < 255; i++) {boolean ok = true;for (int j = 0; j < ROW - 2 && ok; j++) {if (i / exp[j] % 2 == 1 && s[j + 1].charAt(col) == '/') ok = false;else if (i /exp[j] % 2 == 0 && s[j + 1].charAt(col) == '\\') ok = false;}if (ok) return (char)i;}return (char)-1;}private void solve() {int M = s[0].length() - 2;StringBuilder sb = new StringBuilder();for (int i = 1; i <= M; i++) {char ch = check(i);if (ch != -1) sb.append(ch);}cout.println(sb.toString());cout.flush();}public void run(){init();int t = cin.nextInt();while (t-- > 0) {input();solve();}}public static void main(String[] args) {new Thread(new Main()).start();}}
- UVa10851 - 2D Hieroglyphs decoder(枚举)
- UVA 10851 - 2D Hieroglyphs decoder
- uva10851--String暴力
- 学习libopus(2) Decoder解码器
- Ural 1545 Hieroglyphs
- URAL 1545. Hieroglyphs
- MPEG-1/2 Video Decoder API学习
- Codeforces Round #339 (Div. 2) D. Skills(模拟+枚举)
- CF 376D. Maximum Submatrix 2 枚举+前缀和
- codeforces 549D D. Haar Features(枚举)
- D语言中的枚举类型
- Codeforces 617D Polyline 【枚举】
- 2013秋13级预备队集训练习1 D - The Decoder
- 寒假刷题之2——Decoder
- Ecoder & Decoder
- JM14 decoder
- 2010.8 DeCoder
- The Decoder
- linux下执行定时任务
- Android自定义控件实战——水流波动效果的实现WaveView
- python学习笔记(4)-- 函数
- Unable to decode stream: java.io.FileNotFoundException: /android.graphics.Bitmap open failed: ENOEN
- zoj3813 线段树
- UVa10851 - 2D Hieroglyphs decoder(枚举)
- java自定义注解
- 安装java服务器图片处理程序
- mybatis3.2.7事务查询和插入例子
- jsoup抓取网页+详细讲解
- AChartEngine中散列图
- POJ 1325 Machine Schedule(二分匹配 最小点覆盖)
- PHP_Memcache函数详解
- Linux内核驱动之GPIO子系统(一)GPIO的使用