ZCMU-1403-Arne Saknussemm
来源:互联网 发布:人皮客栈知乎 编辑:程序博客网 时间:2024/05/05 10:18
1403: Arne Saknussemm
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 61 Solved: 14
[Submit][Status][Web Board]
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
viator, et terrestre centrum attinges.
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 ofK. For K=19 and the message above, where length(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 19 columns 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
.narctrtria_edrrlen
_gtuerr_,asaneeasf_
si_t_seeovdec_ecenI
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.
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
Sample Output
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ char a[1001][1001]; char b[1001]; int t,i,j,len,count1; while(~scanf("%d",&t)) { len=0; count1=0; for(i=0;i<t;i++) { cin>>a[i]; } for(j=strlen(a[0])-1;j>=0;j--) { for(i=t-1;i>=0;i--) { b[len++]=a[i][j]; } } for(j=0;j<strlen(a[0]);j++) { for(i=0;i<t;i++) { if(a[i][j]=='_') { count1++; } else if(a[i][j]!='_') { goto out; } } } out:; for(i=0;i<len-count1;i++) { if(b[i]=='_') printf(" "); else if(b[i]=='\\') printf("\n"); else printf("%c",b[i]); } printf("\n\n"); } return 0;}
- ZCMU-1403-Arne Saknussemm
- Arne Saknussemm
- Arne Saknussemm
- HDU 1915 Arne Saknussemm
- HDU 1915 Arne Saknussemm
- ZOJ 3121 Arne Saknussemm
- zoj 3121 Arne Saknussemm
- ZOJ3121 POJ3488 Arne Saknussemm
- ZOJ 3121 Arne Saknussemm
- ZOJ 3121 Arne Saknussemm
- POJ 3488 Arne Saknussemm 可能会
- HDU 1915 Arne Saknussemm (解题报告)
- POJ 3488 Arne Saknussemm 字符串译码
- poj 3488 Arne Saknussemm 模拟题
- POJ 3488 & HDU 1915 Arne Saknussemm(模拟)
- POJ - 3488 Arne Saknussemm(水题,细节题)
- zoj3121 Arne Saknussemm(题目没看完,感觉可能是阅读理解题,待ac吧)
- ZCMU—1403
- 如何用JavaScript获取<div>*</div>标签中内容& 内容添加
- 树 耗时 计算 图
- Android爬坑之旅之WebView
- 下载MySQL
- docker 容器中不支持中文的解决方法
- ZCMU-1403-Arne Saknussemm
- 2017.1.17WC模拟赛总结
- RN----导入组件,import from 'xxxx'的用法详解
- 数据库索引的实现原理
- 记一次企业级爬虫系统升级改造(四):爬取微信公众号文章(通过搜狗与新榜等第三方平台)
- Java跨平台
- 多线程-8、dispatch队列
- 23种设计模式——抽象工厂模式
- 动态代理proxy与CGLib