Cryptoquote ; M7 Y$ S4 y$ S' L, ` J
" @) ~4 N+ E" G7 x* z \
: }# P/ L, ?3 M3 V; g6 R
Time Limit: 1000 ms Memory Limit: 65536 kB 4 H5 y |, Q- c- v* ySolved: 79 Tried: 281 0 B; c2 l# s( G3 r6 H0 y
" g6 c' }; ]& t
Description ; @3 L* R; K$ u OA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: - G+ F# _1 S- q6 ^% z2 j( o6 B; f3 m& h: C W+ A' c! O
Encoded: HPC PJVYMIY ; ? X$ A; o# s
Decoded: ACM CONTEST ) [7 ]0 Q; O/ O# J4 U5 y 0 G2 L/ y3 @1 r, `In the example above, H=A, P=C, C=M, J=O, V=N, Y=T, M=E and I=S. For this problem, you will decode messages. 6 O0 i8 ?' K& N: F; \ + J; x1 f% d( i8 U9 J3 S( O4 ^6 I* J T' R! M9 a2 h& J) mInput ! K/ z/ |. m7 }9 _( ~( AThe first line of input contains a single integer N,(1<=N<=1000) which is the number of data sets that follow. Each data set consists of two lines of input. The first line is the encoded message. The second line is a 26 character string of upper case letters giving the character mapping for each letter of the alphabet: the first character gives the mapping for A, the second for B and so on. Only upper case letters will be used. Spaces may appear in the encoded message, and should be preserved in the output string. 9 S$ `% b0 A& N: n6 O* B% b6 J3 n6 I+ I1 ~
) ^8 h0 X6 n+ [3 v. T$ Y! J M4 v! ^7 l
Output $ M/ k2 l/ }4 H; `* ?& }' `
For each data set, you should generate one line of output with the following values: The data set number as a decimal integer (start counting at one), a space and the decoded message. 3 F* M: z+ W2 n7 ?- q1 F & J( B# S5 C; t+ V; `9 Q' \% R( ?8 h: X# `3 c
Sample Input & F# ~3 N. `& V; v. {) m# u
2 5 T) S w7 W* v! X" x1 t( {9 w
HPC PJVYMIY 3 P0 ? Z/ W. T4 M7 f, [0 A ?
BLMRGJIASOPZEFDCKWYHUNXQTV 4 T# g0 _; X8 u6 a' C' o9 [% f( RFDY GAI BG UKMY + l( P' h0 o- z! e0 s
KIMHOTSQYRLCUZPAGWJNBVDXEF 3 ~ m# m y9 L9 | & X1 ]8 b' y/ z/ q" V2 B n, L : A p2 k# b: l/ L0 v: \* d 4 H% f, h2 ^3 {0 l, T2 nSample Output % G3 p- o+ j" O' x3 s7 c) m( w1 ACM CONTEST 1 s2 [" n; f, [1 L& [+ i
2 THE SKY IS BLUE . `$ b+ Z7 L" a* z5 J5 ^& m/ a& I- V( q$ Y1 D T4 Z' N8 v
! U1 y, Q# y0 P5 L, m3 G 3 x7 Y0 J3 ^9 Q6 P( M8 f& X, h我的代码是:- h' n* H0 L$ v: J3 }6 Q' m
#include<stdio.h>0 x0 G7 g( s, r. d
#include<string.h> # q/ l+ I2 m. Z' jint main() 0 N) n; Q. J* Z- K- l) O{ ! a1 w# j# N; Z& e. ^ int N,i,j,k;" i. G2 a9 U0 ^$ [
char c;: `" j2 m0 p T. u0 g
char code[1000];3 r5 Y4 S+ j& O5 W
char map[27];4 h. ?' l% |" S' h
char trans[1000]; % `& \2 ~; e6 ~) X# r char wrong[3];' q+ Z' C8 E) {7 S1 B& z2 u
scanf("%d",&N); 1 w+ D9 K8 W) ]. W0 e) [# G gets(wrong);0 M! K( Y* q S& @7 D: W0 L
int h=1; Y4 L/ Z% h+ ~/ s! m3 [
while(N--): m: J6 x% }$ [" P( m! Q/ d) J
{ 8 `+ Q( U+ E% h: u) b gets(code);9 z0 A$ p9 R: [' Y" J: r5 e
gets(map);! O' { W1 k; S- E6 ^+ o: D
for(i=0;((c=code[i])!='\0');i++) 8 B& ~6 H4 ~1 L. R3 O { # s; }8 R* z, c2 x5 Y6 f' U- U3 C if(c==' ')trans[i]=' ';$ w& T4 P' g- ^( h( Z
else {j=code[i]-'A';' }: K/ e* y% C5 V& k+ s. l
trans[i]=map[j];} }. t1 [8 F) N7 F" G" p
printf("%d ",h); ' z) G! i t# J+ a+ X: H+ p+ u: L for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)0 S/ g) s, O1 U- P4 f9 |3 m
printf("%c",trans[i]); A1 X: K* ]- \2 ^ h++;3 N/ u! ]# f0 l
printf("\n");# ]0 f1 O- m) l. t; c( S: A
}. v: N6 d, J( l% W6 M+ K$ l: ^* u8 z
return 0;9 R @7 p) b o
}, k8 B& T' G% ~/ h
% h' T' q% i1 I' R ' M1 I% X/ P* \6 x. p样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? ; Y( f' M0 T' D# u