Cryptoquote ! A4 D( J( Y! c, I1 f, p4 D) a0 ~
5 ?/ {: S( w7 y/ g N
4 a2 P2 D, S$ g( J Y. I+ E% _
Time Limit: 1000 ms Memory Limit: 65536 kB , F* U" B) P2 d" j9 E; p, h. x w# n6 YSolved: 79 Tried: 281 ! S" r a5 F9 f8 f, o' w' s
/ g( n, z% p; g- T8 p6 t+ p
Description * C. b, u1 e' ]2 N0 Y1 W: d$ iA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ' j4 ~8 q: d( O, S8 N& R+ D A' L) g. i 4 h5 K/ U b6 r$ D' v. a' i OEncoded: HPC PJVYMIY $ y! i/ c1 B! _% t5 m# cDecoded: ACM CONTEST - _6 Y. z6 u8 }% Q6 }( p) R K/ W/ a8 Z$ Y6 C
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. , v w2 r5 r4 N4 L6 e, f- Y% x8 n6 Y* b8 e' m, Y, Y _: {
1 O8 u% x7 b- _5 r( |4 bInput 7 w( g# ]6 u* q
The 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.0 B0 m( U; D4 @- d) R
8 D: {) x2 k6 t6 g3 r6 a
/ |5 F* n3 k4 x; r% |% t! @+ f: R3 h+ A
Output ! @' t0 }9 d/ |$ C' ]
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. * ^! M* W$ L5 s L% L' q" l/ @- p$ }% a' u4 I' l
1 l1 g% ~: W( D/ S" {8 k" e$ O
Sample Input w9 e& l: E* ?% g
2 4 U% X: x8 ?6 T! G9 \& [+ \
HPC PJVYMIY $ U* {- @4 a' Q5 ?4 v1 ]- a
BLMRGJIASOPZEFDCKWYHUNXQTV 6 X6 {1 m' n. R" Q p6 @
FDY GAI BG UKMY + d+ f* t" E6 ^% y/ q- n: y" D
KIMHOTSQYRLCUZPAGWJNBVDXEF & D. `! B0 i! K# i8 k# q1 K, I- z. Q# Q3 C* y( e+ }
3 G% Q6 O9 k* |) ]* F1 U g
2 Y }; c1 M/ E9 u% b
Sample Output ! i2 ^& u2 _9 A7 c3 \1 ACM CONTEST 6 A; r1 S6 T5 \) I( u
2 THE SKY IS BLUE/ Y& s. q r4 j
9 h+ z! Q c' C. N3 g! B" M' m- y 6 K$ e( O: u# B/ C1 o2 C% F, J$ j$ h1 V! I
我的代码是: % [0 \2 k" V+ k- |6 y4 M7 G#include<stdio.h>+ m/ c7 V( k/ D
#include<string.h>( D. |* T4 g& O3 y6 [7 T
int main() " D" g' R/ R0 ?( m: z8 ]{! j" _4 q! o1 @* T1 g% X
int N,i,j,k;" d: l6 ?: q; a$ ? m: C( R X
char c; ) J4 T4 u# T8 p/ H2 w char code[1000];- O6 N, ^7 K# \9 Z* E/ T, T; ]
char map[27]; * T$ Y) {4 b8 z& G* s char trans[1000];% `+ y' K d, |, O6 T
char wrong[3]; ) H3 a( c3 t) J8 \ scanf("%d",&N); 1 Y' E; s" D9 ~+ p( f gets(wrong);6 M- q% R# ?# @6 t- c0 |5 a# t
int h=1; 0 _; z/ A7 S" N" J) T+ g+ l. H while(N--). w9 e) o$ U# r0 h! H" Y. c
{' m' W$ j9 g: ~% c+ e
gets(code);/ \! M7 Z2 p/ M* C- z
gets(map);" r! j z8 V! w, I) l0 y2 |
for(i=0;((c=code[i])!='\0');i++)& W1 s. \. u4 @/ P- F2 j7 T4 k
{+ ~6 w9 \1 ~1 ~& d
if(c==' ')trans[i]=' '; , A2 P2 C/ ~2 a. e2 k else {j=code[i]-'A';& d. [& u6 f# m+ N/ F
trans[i]=map[j];} }/ k! I/ u; ?# p, x2 u- ?
printf("%d ",h);# Y; @/ A* T/ w# x+ l
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)# i' S8 {8 r0 _" |
printf("%c",trans[i]); & F) `8 e) G7 n h++; 6 {1 @4 W, g9 I- p0 }" x0 e printf("\n"); 8 l* D0 S$ g5 ~) W$ ]" z } " g" f1 M7 \4 c! ?9 _0 Q return 0;* t D4 }9 N% V5 s
}& {2 a9 ~1 `) s
3 X) ]+ E e7 m% V; O1 P8 e6 V! ~4 D4 q. G
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? % ^' i, N" N7 a# g9 h' q4 u/ F# V