#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<map> using namespace std; #define pf printf #define sf scanf #define loop(i, n) for(i=0; i<(n); i++) #define MAX 100 map<string, string> mp; int main() { //freopen("in.txt","r",stdin); int n, m; string s1, s2; cin >> n >> m; while(m--) { cin >> s1 >> s2; if(s1.length()>s2.length()) mp[s1] = s2; else mp[s1] = s1; } while(n--) { cin >> s1; cout << mp[s1] << " "; } cout << endl; return 0; }
Subscribe to:
Post Comments (Atom)
Compare equality of two string in C
#include <stdio.h> #include<string.h> int main() { char* country = "Bangladesh"; char* country2; ...
-
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespac...
-
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<ve...
-
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; #define pf printf ...
you need to add two mp[s2] cases
ReplyDelete