Submission #1108714

# Submission time Handle Problem Language Result Execution time Memory
1108714 2024-11-04T20:27:48 Z vicvic Zalmoxis (BOI18_zalmoxis) C++11
0 / 100
25 ms 24312 KB
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
ifstream f ("zalmoxis.in");
ofstream g ("zalmoxis.out");
int n, k, v[1000005], poz, added[1000005], s[1000005], cnt;
void descp (int j)
{
    if (j<=1)
    {
        g << j << " ";
    }
    else if (k>0)
    {
        k--;
        descp (j-1);
        descp (j-1);
    }
    else g << j << " ";
}
void propag ()
{
    while (cnt>=2)
    {
        int a=s[cnt], b=s[cnt-1];
        if (a==b)
        {
            cnt--;
            s[cnt]=a+1;
        }
        else
        {
            return;
        }
    }
}
int main()
{
    f >> n >> k;
    int poz=0, adaugate=0;
    for (int i=1; i<=n; i++)
    {
        int x;
        f >> x;
        while (cnt && s[cnt]<x)
        {
            v[++poz]=s[cnt];
            added[poz]=1;
            k--;
            s[++cnt]=s[cnt-1];
            propag ();
        }
        v[++poz]=x;
        s[++cnt]=x;
        propag ();
    }
    while (s[1]<30)
    {
        k--;
        v[++poz]=s[cnt];
        added[poz]=1;
        s[++cnt]=s[cnt-1];
        propag ();
    }
    for (int i=1; i<=poz; i++)
    {
        if (added[poz])
        {
            descp (v[i]);
        }
        else g << v[i] << " ";
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:51:15: warning: operation on 'cnt' may be undefined [-Wsequence-point]
   51 |             s[++cnt]=s[cnt-1];
      |               ^~~~~
zalmoxis.cpp:51:15: warning: operation on 'cnt' may be undefined [-Wsequence-point]
zalmoxis.cpp:63:11: warning: operation on 'cnt' may be undefined [-Wsequence-point]
   63 |         s[++cnt]=s[cnt-1];
      |           ^~~~~
zalmoxis.cpp:63:11: warning: operation on 'cnt' may be undefined [-Wsequence-point]
zalmoxis.cpp:41:16: warning: unused variable 'adaugate' [-Wunused-variable]
   41 |     int poz=0, adaugate=0;
      |                ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 24144 KB Execution killed with signal 11
2 Runtime error 20 ms 24144 KB Execution killed with signal 11
3 Runtime error 17 ms 24144 KB Execution killed with signal 11
4 Runtime error 17 ms 24144 KB Execution killed with signal 11
5 Runtime error 19 ms 24144 KB Execution killed with signal 11
6 Runtime error 20 ms 24144 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 24232 KB Execution killed with signal 11
2 Runtime error 19 ms 24136 KB Execution killed with signal 11
3 Runtime error 19 ms 24312 KB Execution killed with signal 11
4 Runtime error 19 ms 24292 KB Execution killed with signal 11
5 Runtime error 25 ms 24144 KB Execution killed with signal 11
6 Runtime error 20 ms 24144 KB Execution killed with signal 11
7 Runtime error 20 ms 24144 KB Execution killed with signal 11
8 Runtime error 21 ms 24236 KB Execution killed with signal 11
9 Runtime error 19 ms 24144 KB Execution killed with signal 11
10 Runtime error 18 ms 24144 KB Execution killed with signal 11
11 Runtime error 18 ms 24144 KB Execution killed with signal 11
12 Runtime error 20 ms 24196 KB Execution killed with signal 11
13 Runtime error 20 ms 24144 KB Execution killed with signal 11
14 Runtime error 18 ms 24144 KB Execution killed with signal 11