Submission #221202

# Submission time Handle Problem Language Result Execution time Memory
221202 2020-04-09T16:49:55 Z Gareth618 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
315 ms 9024 KB
#include <fstream>
#define NMAX 1000010
 
std::ifstream fin("zalmoxis.in");
std::ofstream fout("zalmoxis.out");
 
int len;
int v[NMAX];
bool spc[NMAX];
 
int top;
int st[NMAX];
 
inline int min(int x, int y) {
    return x < y ? x : y;
}
 
void print(int val, int cnt) {
    if (cnt == 1) {
        fout << val << ' ';
        return;
    }
    if (cnt == 2) {
        fout << val - 1 << ' ' << val - 1 << ' ';
        return;
    }
 
    int nr = (1 << (val - 1));
    if (cnt <= nr + 1) {
        fout << val - 1 << ' ';
        print(val - 1, cnt - 1);
    }
    else {
        print(val - 1, nr);
        print(val - 1, cnt - nr);
    }
}
 
int main() {
    int n, k; fin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x; fin >> x;
        if (!top || st[top] >= x) {
            v[++len] = st[++top] = x;
            while (top >= 2 && st[top - 1] == st[top])
                st[--top]++;
        }
        else {
            while (st[top] < x) {
                v[++len] = st[top + 1] = st[top]; top++; spc[len] = true;
                while (top >= 2 && st[top - 1] == st[top])
                    st[--top]++;
            }
            v[++len] = st[++top] = x;
            while (top >= 2 && st[top - 1] == st[top])
                st[--top]++;
        }
    }
 
    while (top >= 2 && st[top - 1] == st[top])
        st[--top]++;
    while (st[top] < 30) {
        v[++len] = st[top + 1] = st[top]; top++; spc[len] = true;
        while (top >= 2 && st[top - 1] == st[top])
            st[--top]++;
    }
 
    k -= len - n;
    for (int i = 1; i <= len; i++)
        if (!spc[i])
            fout << v[i] << ' ';
        else {
            print(v[i], min(++k, (1 << v[i])));
            if (k >= (1 << v[i]))
                k -= (1 << v[i]);
            else
                k = 0;
        }
 
    fout << '\n';
    fout.close();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 8696 KB Unexpected end of file - int32 expected
2 Incorrect 305 ms 8824 KB Unexpected end of file - int32 expected
3 Incorrect 315 ms 8696 KB Unexpected end of file - int32 expected
4 Incorrect 315 ms 8824 KB Unexpected end of file - int32 expected
5 Incorrect 309 ms 8924 KB Unexpected end of file - int32 expected
6 Incorrect 304 ms 8696 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 314 ms 9024 KB Unexpected end of file - int32 expected
2 Incorrect 302 ms 8696 KB Unexpected end of file - int32 expected
3 Incorrect 315 ms 8696 KB Unexpected end of file - int32 expected
4 Incorrect 305 ms 8824 KB Unexpected end of file - int32 expected
5 Incorrect 293 ms 8696 KB Unexpected end of file - int32 expected
6 Incorrect 305 ms 8696 KB Unexpected end of file - int32 expected
7 Incorrect 291 ms 8832 KB Unexpected end of file - int32 expected
8 Incorrect 299 ms 8696 KB Unexpected end of file - int32 expected
9 Incorrect 304 ms 8952 KB Unexpected end of file - int32 expected
10 Incorrect 290 ms 8696 KB Unexpected end of file - int32 expected
11 Incorrect 301 ms 8776 KB Unexpected end of file - int32 expected
12 Incorrect 305 ms 8696 KB Unexpected end of file - int32 expected
13 Incorrect 294 ms 8764 KB Unexpected end of file - int32 expected
14 Incorrect 284 ms 8696 KB Unexpected end of file - int32 expected