fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. map<string, string> dct;
  6.  
  7. int main(){
  8. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  9. string s;
  10. while(getline(cin, s)){
  11. if(s == "") break;
  12. ll tmp = s.find(" ");
  13. string k;
  14. for(int i=tmp+1; i<s.length(); i++) k += s[i];
  15. s.erase(tmp);
  16. dct[k] = s;
  17. }
  18.  
  19. while(cin >> s){
  20. if(s == "0") break;
  21. if(dct.find(s) == dct.end()) cout << "eh" << endl;
  22. else cout << dct[s] << endl;
  23. }
  24. }
Success #stdin #stdout 0.01s 5460KB
stdin
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay
0
stdout
cat
eh
loops