Thursday, May 7, 2015

499B - Lecture (Codeforces)

#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;
}

1 comment:

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...