POJ 3488 & HDU 1915 Arne Saknussemm(模拟)
题目链接:
id=3488
HDU: pid=1915">http://acm.hdu.edu.cn/showproblem.php?pid=1915
Description
Following the account of Jules Verne, a scrambled message written by the middle age alchemist Arne Saknussemm, and deciphered by professor Lidenbrock, started the incredible travel to the center of the Earth. The scrambling procedure used by Arne is alike
the procedure given below.
1. Take a non empty message M that contains letters from the English alphabet, digits, commas, dots, quotes (i.e. '), spaces and line breaks, and whose last character is different than space. For example, consider the following message whose translation
reads "In Sneffels's crater descend brave traveler, and touch the center of the Earth".
In Sneffels craterem descende audas |
2. Choose an integral number 0<K≤length(M) and add trailing spaces to M such that the length of the resulting message, say M', is the least multiple of K. For K=19 and the message above, wherelength(M)=74 (including
the 8 spaces and the line break that M contains), two trailing spaces are added yielding the message M' with length(M')=76.
3. Replace all the spaces from M' by the character _ (underscore) ; replace all the line breaks from M' by \ (backslash), and then reverse the message. In our case:
__.segnitta_murtnec_ertserret_te_,rotaiv\sadua_ednecsed_meretarc_sleffenS_nI |
4. Write the message that results from step 3 in a table with length(M')/K rows and K columns. The writing is column wise. For the given example, the message is written in a table with 76/19=4 rows and 19columns as follows:
_ | e | t | m | n | e | e | t | _ | t | \ | u | d | s | m | t | _ | f | S |
_ | g | t | u | e | r | r | _ | , | a | s | a | n | e | e | a | s | f | _ |
. | n | a | r | c | t | r | t | r | i | a | _ | e | d | r | r | l | e | n |
s | i | _ | t | _ | s | e | e | o | v | d | e | c | _ | e | c | e | n | I |
5. The strings of characters that correspond to the rows of the table are the fragments of the scrambled message. The 4 fragments of Arne's message given in step 1 are:
_etmneet_t\udsmt_fS |
_gtuerr_,asaneeasf_ |
Write a program that deciphers non empty messages scrambled as described. The length of a message, before scrambling, is at most 1000 characters, including spaces and line breaks.
Input
The program input is from a text file where each data set corresponds to a scrambled message. A data set starts with an integer n, that shows the number of fragments of the scrambled message, and continues with n strings of characters that designate
the fragments, in the order they appear in the table from step 4 of the scrambling procedure. Input data are separated by white-spaces and terminate with an end of file.
Output
The deciphered message must be printed on the standard output, from the beginning of a line and must be followed by an empty line as shown in the input/output sample below.
Sample Input
4 _etmneet_t\udsmt_fS
_gtuerr_,asaneeasf_
.narctrtria_edrrlen
si_t_seeovdec_ecenI
11 e n r e V _ s e l u J
Sample Output
In Sneffels craterem descende audas
viator, et terrestre centrum attinges. Jules Verne
Source
题意:
把‘_’当作空格。'\\'当作'\n',从最后由下到上输出就可以!
PS:
最后还有空格是不能输出的!
代码例如以下:
#include<stdio.h>
#include<string.h>
char p[1017][1017];
int vis[1017][1017];
int main()
{
int k;
while(scanf("%d",&k)!=EOF)
{
for(int i = 0; i < k; i++)
scanf("%s",p[i]);
int len = strlen(p[0]);
int flag = 0;
memset(vis,0,sizeof vis);
for(int i = 0; i < len; i++)
{
for(int j = 0; j < k; j++)
{
if(p[j][i]=='_')
vis[j][i] = 1;
else
{
flag = 1;
break;
}
}
if(flag)
break;
}
for(int i = len-1; i >= 0; i--)
{
for(int j = k-1; j >= 0; j--)
{
if(vis[j][i])
continue;
if(p[j][i]=='_')
printf(" ");
else if(p[j][i]=='\\')
printf("\n");
else
printf("%c",p[j][i]);
}
}
printf("\n\n");
}
return 0;
}
POJ 3488 & HDU 1915 Arne Saknussemm(模拟)的更多相关文章
- POJ 3344 & HDU 2414 Chessboard Dance(模拟)
题目链接: PKU:http://poj.org/problem? id=3344 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2414 Descrip ...
- HDU 5510---Bazinga(指针模拟)
题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...
- HDU 5047 Sawtooth(大数模拟)上海赛区网赛1006
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 解题报告:问一个“M”型可以把一个矩形的平面最多分割成多少块. 输入是有n个“M",现 ...
- HDU 5965 扫雷 【模拟】 (2016年中国大学生程序设计竞赛(合肥))
扫雷 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submissi ...
- HDU 5935 Car 【模拟】 (2016年中国大学生程序设计竞赛(杭州))
Car Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 5912 Fraction 【模拟】 (2016中国大学生程序设计竞赛(长春))
Fraction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- POJ 3691 & HDU 2457 DNA repair (AC自己主动机,DP)
http://poj.org/problem?id=3691 http://acm.hdu.edu.cn/showproblem.php?pid=2457 DNA repair Time Limit: ...
- POJ 3481 & HDU 1908 Double Queue (map运用)
题目链接: PKU:http://poj.org/problem?id=3481 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1908 Descript ...
随机推荐
- attr和prop的区别
由于prop(property的缩写)和attr(attribute的缩写)翻译成汉语,均有“特性.属性”等意思的原因,导致大家容易混淆分不清. (1)在处理自定义时属性时,用attr(),若用pro ...
- LNOI2019划水记
十二省联考命题组温馨提醒您: 数据千万条,清空第一条. 多测不清空,爆零两行泪. NOIp2018差点退役的游记 $Flag$拔了. $LNOI2019$划水记: $Day0$: 早上八点起床,一直颓 ...
- Sdoi2014 向量集
题目描述 题解: 码力太差重构之后才$A……$ 首先求向量点积最大很容易想到凸包, 设已知$(x_0,y_0)$,求$(x,y)$满足$(x,y)*(x_0,y_0)>=(x',y')*(x_0 ...
- xmind 8 安装后启动失败(未提示错误信息)
xmind 8 安装后启动失败 前言 家里的计算机也安装了xmind,启动之后界面显示xmind的启动图标,几秒之后启动图标消失(闪退了),然后留我一脸懵逼.想着卸载了安装一个新的应该没有问题 ...
- solr中的Tokenizer Filter
Tokenizer Tokenizer 的工作是将文本流分解为令牌,其中每个令牌(通常)是文本中字符的子序列.分析器知道它配置的字段,但 tokenizer 不是.Tokenizers 从字符流(Re ...
- solr 分析器
源https://www.w3cschool.cn/solr_doc Solr 分析器被指定为 schema.xml 配置文件中的<fieldType>元素的子元素(在与 solrconf ...
- 【BZOJ 2761】 不重复数字 (哈希算法)
链接 http://www.lydsy.com/JudgeOnline/problem.php?id=2761 Description 给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如, ...
- luogu1502 窗口的星星
扫描线应该打懒标记的-- #include <algorithm> #include <iostream> #include <cstdio> using name ...
- python mock模块使用(二)
本篇继续介绍mock里面另一种实现方式,patch装饰器的使用,patch() 作为函数装饰器,为您创建模拟并将其传递到装饰函数 官方文档地址 patch简介 1.unittest.mock.patc ...
- php基础语句 变量 符号
中心主题 标记与注释 // /* */ 输出语句 echo输出 echo可以输出多个字符串,逗号隔开 print输出 print只能输出一个字符串,返回true或false print_r() 可以把 ...