ZCMU-1403-Arne Saknussemm
2017-01-17 14:51
330 查看
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 byArne 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. |
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 |
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 |
_etmneet_t\udsmt_fS .narctrtria_edrrlen | _gtuerr_,asaneeasf_ si_t_seeovdec_ecenI |
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 audasviator, et terrestre centrum attinges.
Jules Verne
【解析】
这道题的意思就是把文章给倒置,每一列的元素从下到上组成单词,然后就是'_'代表的是空格,而'\'代表的是换行,但是在我们代码判断的时候需要用'\\'这个来判断。需要注意的是行末的空格我们需要把它去掉所以我们就要统计行末空格的数量。
#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
- ZOJ 3121 Arne Saknussemm
- hdu 1403后缀树裸题
- hdu 1403 Longest Common Substring - 后缀数组
- GoldenGate SQL error 1403 mapping 错误解决方案
- 【ACdream】1403 Graph Game Andrew Stankevich Contest 21 二分匹配——关键点
- POJ - 3488 Arne Saknussemm(水题,细节题)
- Safecracker【ZOJ - - 1403】
- zcmu1672
- zcmu1692
- ZCMU1543 Numbers
- 1403 有趣的堆栈
- zcmu 1091 统计单词数
- ZCMU—1540
- ZCMU—1131
- ZCMU----1778
- ZCMU-1622-判断数
- ZCMU-1478
- ZCMU-1306-狐狸分肉
- ZCMU-1722-围栅栏