Submission #332270

#TimeUsernameProblemLanguageResultExecution timeMemory
332270IgorIDevil's Share (RMI19_devil)C++17
29 / 100
80 ms12072 KiB
#include <bits/stdc++.h> using namespace std; string chk(string s, int k) { string mx = ""; for (int i = 0; i + k <= s.size(); i++) mx = max(mx, s.substr(i, k)); return mx; } string solve(int c1, int c2) { if (c1 == 0) { return string(c2, '2'); } if (c2 % c1 == 0) { string res = ""; for (int i = 0; i < c1; i++) { for (int j = 0; j < c2 / c1; j++) res += "2"; res += "1"; } return res; } vector<int> h(c1, c2 / c1); string g = solve(c1 - c2 % c1, c2 % c1); for (int i = 0; i < h.size(); i++) { if (g[i] == '2') h[i]++; } string res = ""; for (int i = 0; i < h.size(); i++) { for (int j = 0; j < h[i]; j++) res += "2"; res += "1"; } return res; } void solve() { int n = 10; int k = 0; cin >> k; vector<int> d(n); for (int i = 1; i < n; i++) cin >> d[i]; if (0) { string f = string(d[1], '1') + string(d[2], '2'); string ans = f; while (1) { if (chk(f, k) < chk(ans, k)) ans = f; if (!next_permutation(f.begin(), f.end())) break; } cout << ans << "\n"; cout << chk(ans, k) << "\n"; } string ans = ""; if (d[1] == 0) { cout << string(d[2], '2') << "\n"; return; } string s(k - 1, '0'); for (int i = k - 2; i >= 0; i--) { if (d[2]) d[2]--, s[i] = '2'; else d[1]--, s[i] = '1'; } int c1 = d[1], c2 = d[2]; ans = solve(c1, c2) + s; cout << ans << "\n"; //cout << k << "\n"; //cout << chk(ans, k) << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; cin >> t; while (t--) { solve(); } }

Compilation message (stderr)

devil.cpp: In function 'std::string chk(std::string, int)':
devil.cpp:8:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i + k <= s.size(); i++)
      |                     ~~~~~~^~~~~~~~~~~
devil.cpp: In function 'std::string solve(int, int)':
devil.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0; i < h.size(); i++)
      |                     ~~^~~~~~~~~~
devil.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < h.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...