Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std ;
- #define sz(s) int(s.size())
- typedef long long ll ;
- #define all(v) v.begin() , v.end()
- void ABDEL3AL () {
- ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
- #ifndef ONLINE_JUDGE
- freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
- #endif
- }
- int main() {
- ABDEL3AL() ;
- int n , m ; cin >> n >> m ;
- pair <string , string> a[m] ;
- for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second ;
- for (int i = 0; i < n; i++) {
- string word ; cin >> word ;
- for (int j = 0; j < m; j++) {
- if (a[j].first == word || a[j].second == word)
- if (a[j].first.size() == a[j].second.size()) cout << a[j].first << " " ;
- else cout << min(a[j].first , a[j].second) << " " ;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement