v 0. Pasted by slipstak2 as cpp at 2015-01-23 05:32:57 MSK and set expiration to never.

Paste will expire never.

  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. using namespace std;
  5.  
  6. int n;
  7. string message;
  8. map<string, char> mem;
  9. void input() {
  10.     cin>>n;
  11.     char c;
  12.     string code;
  13.     for (int i = 0; i < n; ++i) {
  14.         cin>>c>>code;
  15.         mem[code] = c;
  16.     }
  17.     cin>>message;
  18. }
  19. void solve() {
  20.     string cur;
  21.     for (size_t i = 0; i < message.size(); ++i) {
  22.         cur += message[i];
  23.         if (mem.find(cur) != mem.end()) {
  24.             cout<<mem[cur];
  25.             cur = "";
  26.         }
  27.     }
  28. }
  29. int main() {
  30. #ifdef _DEBUG
  31.     freopen("input.txt","r",stdin);
  32.     freopen("output.txt","w",stdout);
  33. #endif
  34.     input();
  35.     solve();
  36.     return 0;
  37. }


Editing is locked.