forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynchronizinglists.cpp
48 lines (37 loc) · 945 Bytes
/
synchronizinglists.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
int n;
while(cin >> n && n != 0) {
vector<int> l1, l2;
for(int i = 0; i < n; i++) {
int temp;
cin >> temp;
l1.push_back(temp);
}
for(int i = 0; i < n; i++) {
int temp;
cin >> temp;
l2.push_back(temp);
}
vector<int> l1_sorted = l1;
sort(l1_sorted.begin(), l1_sorted.end());
sort(l2.begin(), l2.end());
map<int, int> locations;
for(int i = 0; i < n; i++) {
locations[l1_sorted[i]] = i;
}
vector<int> ret;
for(int i = 0; i < n; i++) {
int pos = locations.find(l1[i])->second;
ret.push_back(l2[pos]);
}
for(auto i : ret) {
cout << i << endl;
}
cout << endl;
}
}