답안 #1108713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108713 2024-11-04T20:25:47 Z vicvic Zalmoxis (BOI18_zalmoxis) C++11
0 / 100
42 ms 48116 KB
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
ifstream f ("zalmoxis.in");
ofstream g ("zalmoxis.out");
int n, k, v[2000005], poz, added[2000005], s[2000005], 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 ();
    }
    assert (k>=0);
    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;
      |                ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 48008 KB Execution killed with signal 11
2 Runtime error 34 ms 48116 KB Execution killed with signal 11
3 Runtime error 34 ms 47952 KB Execution killed with signal 11
4 Runtime error 35 ms 48088 KB Execution killed with signal 11
5 Runtime error 36 ms 47944 KB Execution killed with signal 11
6 Runtime error 38 ms 47944 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 47980 KB Execution killed with signal 11
2 Runtime error 35 ms 47964 KB Execution killed with signal 11
3 Runtime error 36 ms 47956 KB Execution killed with signal 11
4 Runtime error 35 ms 47968 KB Execution killed with signal 11
5 Runtime error 36 ms 48084 KB Execution killed with signal 11
6 Runtime error 39 ms 47964 KB Execution killed with signal 11
7 Runtime error 42 ms 48008 KB Execution killed with signal 11
8 Runtime error 35 ms 47980 KB Execution killed with signal 11
9 Runtime error 41 ms 47956 KB Execution killed with signal 11
10 Runtime error 36 ms 47956 KB Execution killed with signal 11
11 Runtime error 36 ms 48076 KB Execution killed with signal 11
12 Runtime error 36 ms 48108 KB Execution killed with signal 11
13 Runtime error 35 ms 48096 KB Execution killed with signal 11
14 Runtime error 37 ms 47960 KB Execution killed with signal 11