Submission #78937

# Submission time Handle Problem Language Result Execution time Memory
78937 2018-10-09T16:40:01 Z bogdan10bos Zalmoxis (BOI18_zalmoxis) C++14
5 / 100
1000 ms 68072 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, K - M);
            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 232 ms 31480 KB Unexpected end of file - int32 expected
2 Incorrect 242 ms 33588 KB Unexpected end of file - int32 expected
3 Incorrect 233 ms 35856 KB Unexpected end of file - int32 expected
4 Incorrect 287 ms 37824 KB Unexpected end of file - int32 expected
5 Incorrect 237 ms 39868 KB Unexpected end of file - int32 expected
6 Incorrect 232 ms 41980 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 44024 KB Expected EOF
2 Correct 247 ms 46128 KB Output is correct
3 Incorrect 233 ms 48172 KB Expected integer, but "04" found
4 Incorrect 236 ms 48336 KB Expected EOF
5 Incorrect 234 ms 48336 KB Expected EOF
6 Incorrect 268 ms 48336 KB Expected EOF
7 Incorrect 234 ms 48336 KB Unexpected end of file - int32 expected
8 Incorrect 254 ms 48344 KB Expected EOF
9 Execution timed out 1056 ms 66920 KB Time limit exceeded
10 Execution timed out 1061 ms 68072 KB Time limit exceeded
11 Execution timed out 1088 ms 68072 KB Time limit exceeded
12 Incorrect 25 ms 68072 KB Unexpected end of file - int32 expected
13 Incorrect 23 ms 68072 KB Unexpected end of file - int32 expected
14 Incorrect 26 ms 68072 KB Unexpected end of file - int32 expected