Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- string input;
- cin >> input;
- int n = 0;
- cin >> n;
- vector<pair<string, int>> str(n);
- for (auto& i : str)
- cin >> i.first >> i.second;
- int64_t ans = 0;
- for (int i = 0; i < input.size(); i++)
- {
- for (const auto& s : str)
- {
- if (s.first.size() > i + 1)
- continue;
- bool find = true;
- for (int q = 0; q < s.first.size(); q++)
- {
- if (input[i - s.first.size() + q + 1] != s.first[q])
- {
- find = false;
- break;
- }
- }
- if (find)
- ans += s.second;
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement