Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 6911 | Accepted: 3979 |
Description
A | .- | H | .... | O | --- | V | ...- |
B | -... | I | .. | P | .--. | W | .-- |
C | -.-. | J | .--- | Q | --.- | X | -..- |
D | -.. | K | -.- | R | .-. | Y | -.-- |
E | . | L | .-.. | S | ... | Z | --.. |
F | ..-. | M | -- | T | - | ||
G | --. | N | -. | U | ..- |
underscore | ..-- | period | ---. |
comma | .-.- | question mark | ---- |
Input
Output
Sample Input
5 AKADTOF_IBOETATUK_IJN PUEL QEWOISE.EIVCAEFNRXTBELYTGD. ?EJHUT.TSMYGW?EJHOT DSU.XFNCJEVE.OE_UJDXNO_YHU?VIDWDHPDJIKXZT?E
Sample Output
1: ACM_GREATER_NY_REGION 2: PERL 3: QUOTH_THE_RAVEN,_NEVERMORE. 4: TO_BE_OR_NOT_TO_BE? 5: THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG
Source
#include <cstdio> #include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <map> #include <string> #include <stack> #include <ctype.h> #include <vector> #include <queue> #include <set> using namespace std; #define MAXN 10 #define Inf 0x7ffffff #define eps 1e10-8 #define mod 1000000007 typedef long long LL; const double PI = acos(-1.0); typedef double D; //#define Online_Judge #define outstars cout << "***********************" << endl; #define REP(i , n) for(int i = 0 ; i < n ; i++) int n ; char s[120]; map<string , char>retran; map<char ,string>tran; int main() { #ifdef Online_Judge freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif // Online_Judge tran['A'] = ".-"; tran['B'] = "-..."; tran['C'] = "-.-."; tran['D'] = "-.."; tran['E'] = "."; tran['F'] = "..-."; tran['G'] = "--."; tran['H'] = "...."; tran['I'] = ".."; tran['J'] = ".---"; tran['K'] = "-.-"; tran['L'] = ".-.."; tran['M'] = "--"; tran['N'] = "-."; tran['O'] = "---"; tran['P'] = ".--."; tran['Q'] = "--.-"; tran['R'] = ".-."; tran['S'] = "..."; tran['T'] = "-"; tran['U'] = "..-"; tran['V'] = "...-"; tran['W'] = ".--"; tran['X'] = "-..-"; tran['Y'] = "-.--"; tran['Z'] = "--.."; tran['_'] = "..--"; tran['.'] = "---."; tran[','] = ".-.-"; tran['?'] = "----"; retran[".-"] = 'A'; retran["-..."] = 'B'; retran["-.-."] = 'C'; retran["-.."] = 'D'; retran["."] = 'E'; retran["..-."] = 'F'; retran["--."] = 'G'; retran["...."] = 'H'; retran[".."] = 'I'; retran[".---"] = 'J'; retran["-.-"] = 'K'; retran[".-.."] = 'L'; retran["--"] = 'M'; retran["-."] = 'N'; retran["---"] = 'O'; retran[".--."] = 'P'; retran["--.-"] = 'Q'; retran[".-."] = 'R'; retran["..."] = 'S'; retran["-"] = 'T'; retran["..-"] = 'U'; retran["...-"] = 'V'; retran[".--"] = 'W'; retran["-..-"] = 'X'; retran["-.--"] = 'Y'; retran["--.."] = 'Z'; retran["..--"] = '_'; retran["---."] = '.'; retran[".-.-"] = ','; retran["----"] = '?'; scanf("%d",&n); stack <int> S; for(int k = 1 ; k <= n ; k++) { string s1 , s2 ; s1 = ""; while(!S.empty()) { S.pop(); } scanf("%s",s); cout<<k<<": "; int len = strlen(s); for(int i = 0 ; i < len ; i++) { s1 += tran[s[i]]; S.push(tran[s[i]].length()); } int j = 0; while(!S.empty()) { int x = S.top(); S.pop(); s2 = ""; while(x--) { s2 += s1[j++]; } cout << retran[s2]; } cout << endl; } return 0; } /* */