Cryptoquote ( N+ W2 D8 X& G2 f: S& j 2 Z+ v+ Z2 {/ |. y V0 Q: k% X1 R/ F: p- k, d! I- ?5 r
Time Limit: 1000 ms Memory Limit: 65536 kB2 @; r' \5 U3 {% o, m8 L" R
Solved: 79 Tried: 281 $ ?6 t2 ^/ [5 p
+ N2 D3 M+ h/ @
Description & p% R" F R O& cA cryptoquote is a ** encoded message where one letter is simply replaced by another throughout the message. For example: ! y8 P/ P0 `0 |, G' T& l& x9 [( r% V# K! Y0 z
Encoded: HPC PJVYMIY 8 F: [" s5 }/ F+ NDecoded: ACM CONTEST ( Q0 m8 B# A4 v$ A! Z 8 q' Q8 y- }4 h7 x! O/ ?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. _. {, b! L- t1 B
1 }+ |( t7 R; [/ s2 O, {" c
1 x8 N; A1 ~% | A. s& S( v# GInput : e1 |1 `& E6 H8 A* e7 B7 E8 T2 x
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.! K/ s4 ~1 w- A3 i+ X- s
' o' _' }. t) F0 ^2 A% T
5 ?9 X; b4 q2 s1 r# z/ d* M! h5 h! w- e" r$ T5 X% c# h5 m
Output ( T6 Z+ d; q( r* \; S2 s$ ~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. 5 D4 ?- K1 ^6 P# }8 }
: `* q* O% B& M# X$ c3 q! ?' T7 N8 g
Sample Input + D' E1 Q h, z. _2 % f# B% ^1 g( l7 g
HPC PJVYMIY , c( u a9 H) v8 XBLMRGJIASOPZEFDCKWYHUNXQTV * g! j/ B4 p1 l8 Q
FDY GAI BG UKMY 8 c' F: e/ {! W# SKIMHOTSQYRLCUZPAGWJNBVDXEF 5 c/ k. P# n; g n2 m6 n, Z1 V1 M! R j* r, K) A
8 Z3 U* r1 V6 x }
6 }- V K4 `+ w/ E% _2 ^* O
Sample Output 0 r, }8 |9 C* |8 W% E5 P6 X
1 ACM CONTEST $ n3 y1 Q5 b; z2 l; e2 `+ l4 @
2 THE SKY IS BLUE 4 {; Q% v3 u) \0 n" y! n + T6 f( g- G- [" X" A4 h ) U. a9 u2 Z& \) z' j U% u3 c3 t7 ~4 i: B4 h( X
我的代码是: ( i* b& s/ S& ~9 p#include<stdio.h>5 L9 l* V# u( V
#include<string.h>+ c+ }$ Q3 U3 w+ z- h# s4 W
int main() # b. I5 K7 c' c' d{5 T) E" Z) i6 K* Y! w5 u3 d- \6 f
int N,i,j,k;% u, \9 o; ~/ z/ V* u+ K2 B' a5 q
char c;; v8 z$ |: G/ t3 J3 m% N3 a, F
char code[1000];8 q& y4 y$ y+ d9 Z$ j2 m
char map[27];- }8 }3 D5 X6 L9 ]$ p
char trans[1000]; 0 J% D' |5 c- ~+ z char wrong[3]; / @& c6 X* {* ~; u scanf("%d",&N);$ o/ j3 c6 o7 n- }5 ` Z) h) L) D
gets(wrong);! s( x! A0 [3 s
int h=1; / v+ Q8 a4 b2 E6 s" b } while(N--)1 Q) B h7 J( p$ ~( m/ ?
{ 4 Z; Q3 Z# c) r3 l7 C' @ gets(code);9 E& }, h- |( a5 v' j' k
gets(map); - m9 k8 ]3 z2 R, U, J5 r for(i=0;((c=code[i])!='\0');i++) 5 B5 m' M0 j% m {0 O. e2 d8 z( e9 G3 ^2 i
if(c==' ')trans[i]=' '; - ^7 I) K A8 N else {j=code[i]-'A';& q/ ~! Y5 B, w) k. F. k
trans[i]=map[j];} }. @) b5 J" N. T4 G
printf("%d ",h);2 D9 j9 O) {5 N* L& q' v
for(i=0;((k=trans[i]<=90)&&(k=trans[i]>=65)||(k=trans[i]==' '));i++)7 `$ _0 K/ u" H$ T; i
printf("%c",trans[i]); 7 s3 ?5 a/ V- E |+ \ h++; - H/ L# ^* c2 a5 @9 Q; W$ u printf("\n"); 8 ~/ v1 t! s+ V O2 _4 X1 p4 O } / x2 g1 Z; f9 G; _- z4 n3 c/ T) A return 0; 8 J g3 b5 \. j} 9 z. j% A$ s" v! O% ~ x( P: ~1 z/ g6 p: W, p
1 f, ~' s: C1 M. {. Q
样例过了,但是提交答案的时候还是wrong answer。是哪里有陷阱? - n; u& p- }2 r, Q