' v9 S }3 Y7 K 5 o* S! h; \) w4 [1 ATime Limit: 1000 ms Memory Limit: 65536 kB2 o; Y- w; u) D
Solved: 79 Tried: 281 # M2 O# ] ~0 N8 u2 R9 R
" w5 C" {! e: E! F- M
Description " b. ?, Y* A" \5 c* `- {. SA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example:: }0 o9 k. Q! ~( V% O
1 M* H' S/ b: f# T5 sEncoded: HPC PJVYMIY 0 C L A( k. \7 Q1 c6 L
Decoded: ACM CONTEST, `* O7 Y! |# M% r' R @1 A4 l
* C% f8 X8 \. g+ k/ E- y$ x7 ^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. / E. y# E2 v' ^8 T0 E7 g2 y
& L* q" F. z: b+ Y2 w+ r , e9 u. j1 B5 `Input $ N( r7 ]% N* ]' W! 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. 4 O. p8 a: n9 s3 p$ w) e$ Q' U6 b2 O/ d% s2 ^. y4 I7 ?
+ \, {2 n9 L+ q% ?
2 O7 |' I5 @5 g: L0 I
Output 4 B/ P5 t% g5 w9 K, A+ ]* RFor 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. u5 S! r0 P0 k9 A: [0 k9 g: w
; U* p. W. k& s- i1 Q5 R; V) S* c; ]- n; z& B v
Sample Input - ~1 i# p2 h5 M+ Q
2 - i3 m! u, l0 r& N; T9 A
HPC PJVYMIY ' Q! I- N# g; h$ NBLMRGJIASOPZEFDCKWYHUNXQTV 6 S. Y8 E+ U+ uFDY GAI BG UKMY / }; D5 [ y/ ` q8 W: bKIMHOTSQYRLCUZPAGWJNBVDXEF$ o/ H- A4 b; X0 q
9 T* x8 f+ n) `3 z1 A: Z# N1 G
: f5 t x1 N) v& Y% ~
- ?3 g2 ?# }# n/ {7 ^
Sample Output : h8 p. H/ L) M; T! j# L1 ACM CONTEST ; d( ]. F7 |+ ?. E$ S2 THE SKY IS BLUE / M6 \ S% [1 T* x {1 M5 D ) Z( T+ U( K" W0 U5 k 2 N6 y9 I" V$ x' J" x# P 6 n) r4 E. t8 y6 l# E我的代码是:9 G8 O9 I7 D/ d9 ^3 s ^# v" }7 C
#include<stdio.h>7 {" o8 `9 s5 y7 y
#include<string.h> # F6 h( `# o% S6 q9 _+ w7 }% [int main(), m8 N3 K I: I ]4 F8 e
{6 Q0 m' `+ _, C( D t
int N,i,j,k;5 a0 {) r1 V9 P9 V) e* Z8 d
char c; : T. n" ^7 g/ p$ V1 ^" K- J$ B# ]) V char code[1000];2 k: i1 f- k. a! I
char map[27];1 O- C8 ?6 I4 t. w' a
char trans[1000]; 6 }% m5 W. Z. \ char wrong[3]; 3 t$ @! {1 n1 E, o: Z8 d scanf("%d",&N); ! i7 f5 X7 ~' R% G8 A) x gets(wrong); ) f4 `$ Z- Q" B( D( S7 X int h=1; % u, Y( F9 P8 j9 f while(N--) 7 R# B Y! u- H {- T: W, z7 p8 z" i7 K9 J9 C
gets(code);: h, @* Y4 ?+ q- n2 q
gets(map); o: q: R/ ]4 K for(i=0;((c=code[i])!='\0');i++)9 N8 N y5 w% x, U- E4 V6 G
{+ b7 d& |6 v; |* s' S [
if(c==' ')trans[i]=' '; r, |2 {$ K4 E
else {j=code[i]-'A'; 1 R/ L6 s; n7 o trans[i]=map[j];} } 3 O( _. n& I* x8 {8 `5 l printf("%d ",h);' C/ H' G! o* Y$ h
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++) 6 Z! `# @6 Z1 u printf("%c",trans[i]); 0 @/ `/ C3 a7 T! W; V h++;. g4 ]- G4 Z0 p4 R4 v# e
printf("\n"); 1 C {0 U1 O2 I: g } ! z4 `$ P1 m; G# \0 x" c return 0; 1 y' n) C2 U9 E0 I- P* O* u} @! J2 q- u, k/ F& C* `5 N+ T/ V
W q3 u9 c8 h5 b
" e# P) h4 i5 m# `! P, Z& j; i4 U样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? ) v+ I, j) T6 D: P