Untitled
unknown
c_cpp
4 months ago
849 B
6
Indexable
#include <bits/stdc++.h> using namespace std; void MO3TAZOLEQ() { #ifdef MOATAZOLEQ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } #define ll long long void solve() { int n, m; cin >> n >> m; map<string, string> dictionary; for (int i = 0; i < m; i++) { string a, b; cin >> a >> b; dictionary[a] = b; } for (int i = 0; i < n; ++i) { string word; cin >> word; string translated = dictionary[word]; if (word.size() <= translated.size()) { cout << word << " "; } else { cout << translated << " "; } } } int main() { MO3TAZOLEQ(); ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }
Editor is loading...
Leave a Comment