Submission #1061300

#TimeUsernameProblemLanguageResultExecution timeMemory
1061300kunzaZa183Copy and Paste 3 (JOI22_copypaste3)C++17
15 / 100
3060 ms1364 KiB
#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)

copypaste3.cpp: In function 'long long int appear(std::string, std::string)':
copypaste3.cpp:7:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |   for (int i = 0; i < big.size(); i++)
      |                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...