Submission #1089869

# Submission time Handle Problem Language Result Execution time Memory
1089869 2024-09-17T10:36:48 Z lucri Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
110 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
int n,k,v[1000010];
queue<int>ad[1000010];
vector<pair<int,int>>val[35];
void scrie(int val)
{
    if(val==0||k==0)
    {
        cout<<val<<' ';
        return;
    }
    --k;
    scrie(val-1);
    scrie(val-1);
    return;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        cin>>v[i];
        val[v[i]].push_back({i,i});
    }
    for(int va=0;va<=29;++va)
    {
        sort(val[va].begin(),val[va].end());
        int sz=val[va].size();
        for(int i=0;i<sz;++i)
        {
            if(i+1==sz||val[va][i].second+1!=val[va][i+1].first)
            {
                --k;
                ad[val[va][i].second].push(va);
                val[va+1].push_back(val[va][i]);
            }
            else
            {
                val[va+1].push_back({val[va][i].first,val[va][i+1].second});
                ++i;
            }
        }
    }
    /*if(k<0)
        return -1;
    if(val[30].size()!=1)
        return -1;
    if(val[30][0].first!=1||val[30][0].second!=n)
        return -1;*/
    for(int i=1;i<=n;++i)
    {
        cout<<v[i]<<' ';
        while(!ad[i].empty())
        {
            scrie(ad[i].front());
            ad[i].pop();
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 90 ms 262144 KB Execution killed with signal 9
2 Runtime error 102 ms 262144 KB Execution killed with signal 9
3 Runtime error 97 ms 262144 KB Execution killed with signal 9
4 Runtime error 89 ms 262144 KB Execution killed with signal 9
5 Runtime error 92 ms 262144 KB Execution killed with signal 9
6 Runtime error 95 ms 262144 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Runtime error 109 ms 262144 KB Execution killed with signal 9
2 Runtime error 103 ms 262144 KB Execution killed with signal 9
3 Runtime error 101 ms 262144 KB Execution killed with signal 9
4 Runtime error 100 ms 262144 KB Execution killed with signal 9
5 Runtime error 110 ms 262144 KB Execution killed with signal 9
6 Runtime error 108 ms 262144 KB Execution killed with signal 9
7 Runtime error 106 ms 262144 KB Execution killed with signal 9
8 Runtime error 101 ms 262144 KB Execution killed with signal 9
9 Runtime error 97 ms 262144 KB Execution killed with signal 9
10 Runtime error 105 ms 262144 KB Execution killed with signal 9
11 Runtime error 105 ms 262144 KB Execution killed with signal 9
12 Runtime error 97 ms 262144 KB Execution killed with signal 9
13 Runtime error 101 ms 262144 KB Execution killed with signal 9
14 Runtime error 107 ms 262144 KB Execution killed with signal 9