Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <set>
- using namespace std;
- int main() {
- int constraints;
- cin >> constraints;
- cin.ignore();
- set<string> open_tabs;
- for (int i = 0; i < constraints; i++)
- {
- string tab;
- getline(cin, tab);
- open_tabs.insert(tab);
- }
- set<string> untrusted_sites = { "bg-mama.bg", "planeta.bg", "moodle.bg" };
- string album_title;
- while (true)
- {
- string word, web;
- cin >> word;
- if (word == "STOP") break;
- cin >> web;
- if (open_tabs.count(web) && !untrusted_sites.count(web))
- {
- if (!album_title.empty())
- {
- album_title += " ";
- }
- album_title += word;
- }
- }
- cin.ignore();
- while (true)
- {
- string action;
- cin >> action;
- if (action == "STOP") break;
- if (action == "REPLACE")
- {
- string old_text, result;
- cin >> old_text >> result;
- size_t pos = 0;
- while ((pos = album_title.find(old_text, pos)) != string::npos)
- {
- album_title.replace(pos, old_text.length(), result);
- pos += result.length();
- }
- }
- else if (action == "REMOVE")
- {
- string text_to_remove;
- cin >> text_to_remove;
- size_t pos = album_title.find(text_to_remove);
- if (pos != string::npos)
- {
- album_title.erase(pos, text_to_remove.length());
- }
- }
- cin.ignore();
- }
- cout << album_title << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement