Uva 482 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, j = 1;
    cin >> n;
    getchar();

    while(n--)
    {
        getchar();

        if(j > 1)
        {
            cout << endl;
        }

        string s, x;

        getline(cin, s);
        getline(cin, x);

        vector<int>v1;
        vector<string>v2;

        stringstream ss(s);
        stringstream sx(x);

        int p;
        while(ss >> p)
        {
            v1.push_back(p);
        }

        string p1;
        while(sx >> p1)
        {
            v2.push_back(p1);
        }

        map<int, string>mp;
        for(i=0;i<v1.size();i++)
        {
            mp[v1[i]] = v2[i];
        }

        for(auto it=mp.begin();it !=mp.end();it++)
        {
            cout << it->second << endl;
        }

        j++;
    }
    return 0;
}

Comments