Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lectricas/497e19dd336eaffb70dc46c648089f0f to your computer and use it in GitHub Desktop.
Save lectricas/497e19dd336eaffb70dc46c648089f0f to your computer and use it in GitHub Desktop.
#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