Created
June 6, 2021 22:10
-
-
Save lectricas/497e19dd336eaffb70dc46c648089f0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <unordered_map> | |
#include <sstream> | |
using namespace std; | |
string insert(string &input, unordered_map<int, string> &sorted) { | |
for (int i = 0; i < input.size(); i++) { | |
if (sorted.count(i) != 0) { | |
cout << sorted[i]; | |
} | |
cout << input[i]; | |
} | |
if (sorted.count(input.size()) != 0) { | |
cout << sorted[input.size()]; | |
} | |
} | |
int main() { | |
string input; | |
getline(cin, input); | |
int n; | |
cin >> n; | |
cin.ignore(); | |
unordered_map<int, string> map; | |
for (int i = 0; i < n; i++) { | |
string line; | |
getline(std::cin, line); | |
istringstream iss(line); | |
string str; | |
int index; | |
iss >> str; | |
iss >> index; | |
map[index] = str; | |
} | |
insert(input, map); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment