fork download
  1. #include "bits/stdc++.h"
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int dictSize, size;
  7. cin >> size >> dictSize;
  8. map<string, string> dict;
  9. for (int i = 0; i < dictSize; i++) {
  10. string word1, word2;
  11. cin >> word1 >> word2;
  12. dict[word1] = word2;
  13. }
  14. for (int i = 0; i < size; i++) {
  15. string word;
  16. cin >> word;
  17. if (word.size() > dict[word].size()) cout << dict[word] << " ";
  18. else cout << word << " ";
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout