Submission #78939

# Submission time Handle Problem Language Result Execution time Memory
78939 2018-10-09T16:41:09 Z bogdan10bos Zalmoxis (BOI18_zalmoxis) C++14
5 / 100
270 ms 32612 KB
#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

int N, K, M;
int v[1000005];
vector<int> stv, add[1000005];

int printmore(int x, int need)
{
    if(x == 0)
    {
        printf("%d ", x);
        return 0;
    }

    if(need == 0)
    {
        printf("%d ", x);
        return 0;
    }

    if(need == 1)
    {
        printf("%d %d", x - 1, x - 1);
        return 1;
    }

    need--;
    int lft = need / 2;
    int rgt = need - lft;
    int tot = printmore(x - 1, lft) + printmore(x - 1, rgt) + 1;
    return tot;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]);
    v[N + 1] = 30;
    stv.push_back(v[1]);
    for(int i = 2; i <= N; i++)
    {
        while(stv.back() < v[i])
        {
            int val = stv.back();
            stv.pop_back();
            if(!stv.empty() && stv.back() == val)
            {
                stv.pop_back();
                stv.push_back(val + 1);
                continue;
            }

            add[i - 1].push_back(val); M++;
            stv.push_back(val + 1);
        }
        while((int)stv.size() > 1)
        {
            int x = stv.back();
            stv.pop_back();
            int y = stv.back();
            if(x == y)
            {
                stv.pop_back();
                stv.push_back(x + 1);
                continue;
            }
            stv.push_back(x);
            break;
        }
        stv.push_back(v[i]);
        while((int)stv.size() > 1)
        {
            int x = stv.back();
            stv.pop_back();
            int y = stv.back();
            if(x == y)
            {
                stv.pop_back();
                stv.push_back(x + 1);
                continue;
            }
            stv.push_back(x);
            break;
        }
    }

    assert(M <= K);
    int more = K - M;
    for(int i = 1; i <= N; i++)
    {
        printf("%d ", v[i]);
        for(auto x: add[i])
        {
            int pr = printmore(x, more);
            more -= pr;
        }
    }
    printf("\n");

    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &K);
     ~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:46:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= N; i++) scanf("%d", &v[i]);
                                 ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 29816 KB Unexpected end of file - int32 expected
2 Incorrect 235 ms 29868 KB Unexpected end of file - int32 expected
3 Incorrect 234 ms 29896 KB Unexpected end of file - int32 expected
4 Incorrect 239 ms 29896 KB Unexpected end of file - int32 expected
5 Incorrect 243 ms 29896 KB Unexpected end of file - int32 expected
6 Incorrect 227 ms 29896 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 29980 KB Unexpected end of file - int32 expected
2 Correct 219 ms 29980 KB Output is correct
3 Incorrect 232 ms 30072 KB Unexpected end of file - int32 expected
4 Incorrect 234 ms 30112 KB Unexpected end of file - int32 expected
5 Incorrect 237 ms 30112 KB Unexpected end of file - int32 expected
6 Incorrect 235 ms 30120 KB Unexpected end of file - int32 expected
7 Incorrect 227 ms 30120 KB Unexpected end of file - int32 expected
8 Incorrect 270 ms 30120 KB Unexpected end of file - int32 expected
9 Incorrect 220 ms 32612 KB Expected integer, but "01" found
10 Incorrect 162 ms 32612 KB Unexpected end of file - int32 expected
11 Incorrect 198 ms 32612 KB Expected integer, but "01" found
12 Incorrect 23 ms 32612 KB Unexpected end of file - int32 expected
13 Incorrect 22 ms 32612 KB Unexpected end of file - int32 expected
14 Incorrect 23 ms 32612 KB Unexpected end of file - int32 expected