Submission #332260

# Submission time Handle Problem Language Result Execution time Memory
332260 2020-12-01T19:50:37 Z IgorI Devil's Share (RMI19_devil) C++17
0 / 100
41 ms 1516 KB
#include <bits/stdc++.h>

using namespace std;

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 (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];
    vector<int> h(c1, c2 / c1);
    int add = c2 % c1;
    //cout << c2 << " " << c1 << endl;
    if (add > 0)
    {
        for (int st = h.size(); st >= 1; st--)
        {
            if (h.size() / st >= add)
            {
                for (int i = 0; i < h.size(); i += st)
                {
                    if (add)
                        add--, h[i]++;
                }
                //cout << add << endl;
                break;
            }
        }
    }
    for (auto e : h)
    {
        for (int i = 0; i < e; i++)
            cout << "2";
        cout << "1";
    }
    cout << s << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Compilation message

devil.cpp: In function 'void solve()':
devil.cpp:34:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |             if (h.size() / st >= add)
      |                 ~~~~~~~~~~~~~~^~~~~~
devil.cpp:36:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 for (int i = 0; i < h.size(); i += st)
      |                                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 748 KB Token parameter [name=X] equals to "222222", doesn't correspond to pattern "[0-9]{31}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6 (could be triggered by violating memory limits)