Submission #332273

#TimeUsernameProblemLanguageResultExecution timeMemory
332273IgorIDevil's Share (RMI19_devil)C++17
29 / 100
307 ms12196 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; } string construct(int c1, int c2, int k) { string ans = ""; if (c1 == 0) { return string(c2, '2'); } string s(k - 1, '0'); for (int i = k - 2; i >= 0; i--) { if (c2) c2--, s[i] = '2'; else c1--, s[i] = '1'; } ans = solve(c1, c2) + s; return ans; } void solve() { int n = 10; int k = 0; cin >> k; vector<int> d(n); for (int i = 1; i < n; i++) cin >> d[i]; int S = accumulate(d.begin(), d.end(), 0); int p = 0; vector<string> s; s.push_back(construct(0, S, k)); for (int i = 1; i < n; i++) { p += d[i]; s.push_back(construct(p, S - p, k)); } string ans(S, '.'); for (int i = 1; i < n; i++) { for (int j = 0; j < S; j++) { if (ans[j] == '.' && s[i][j] == '1') ans[j] = i + '0'; } } cout << ans << "\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...