Advertisement
MohamedAbdel3al

B. Lecture

Sep 17th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6. #define all(v) v.begin() , v.end()
  7.  
  8. void ABDEL3AL () {
  9. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  12. #endif
  13. }
  14.  
  15. int main() {
  16. ABDEL3AL() ;
  17. int n , m ; cin >> n >> m ;
  18. pair <string , string> a[m] ;
  19. for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second ;
  20. for (int i = 0; i < n; i++) {
  21. string word ; cin >> word ;
  22. for (int j = 0; j < m; j++) {
  23. if (a[j].first == word || a[j].second == word)
  24. if (a[j].first.size() == a[j].second.size()) cout << a[j].first << " " ;
  25. else cout << min(a[j].first , a[j].second) << " " ;
  26. }
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement