# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061300 | kunzaZa183 | Copy and Paste 3 (JOI22_copypaste3) | C++17 | 3060 ms | 1364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
map<string, int> msi;
int appear(string big, string small) {
int ct = 0;
for (int i = 0; i < big.size(); i++)
if (small == big.substr(i, small.size())) {
ct++;
i += small.size() - 1;
}
return ct;
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
string s;
cin >> s;
int add, cut, paste;
cin >> add >> cut >> paste;
for (int i = 0; i < n; i++)
msi[s.substr(i, 1)] = add;
for (int i = 2; i <= n; i++) {
for (int j = 0; j < n; j++) {
if (!msi.count(s.substr(j, i))) {
int mini = add * i;
for (auto a : msi) {
int x = appear(s.substr(j, i), a.first);
mini = min(mini, a.second + cut + paste * x +
(i - x * int64_t(a.first.size())) * add);
}
msi[s.substr(j, i)] = mini;
}
}
}
cout << msi[s] << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |