Submission #335452

# Submission time Handle Problem Language Result Execution time Memory
335452 2020-12-12T16:58:14 Z 3funnn Zalmoxis (BOI18_zalmoxis) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define mp make_pair
 
using namespace std;
 
const int NMAX = 1000000;
int need;
 
void dfs(int val){
    if (need == 0 || val == 0){
        fout << val << " ";
        return;
    }
    --need;
    dfs(val - 1);
    dfs(val - 1);
}
 
int stk[NMAX + 5], top;
 
void Compress(){
    while (top >= 2 && stk[top] == stk[top - 1]){
        --top;
        ++stk[top];
    }
}
 
int main()
{
    int N, K;
    cin >> N >> K;
    vector <int> v(N);
    for (int i = 0;i < N;++i)
        cin >> v[i];
    need = K;
    vector <pair <int, bool>> a;
    stk[++top] = 31;
    for (int i = 0;i < N;++i){
        while (v[i] > stk[top]){
            --need;
            a.push_back(mp(stk[top], true));
            ++stk[top];
            Compress();
        }
        a.push_back(mp(v[i], false));
        stk[++top] = v[i];
        Compress();
    }
    while (stk[2] != 30){
        --need;
        a.push_back(mp(stk[top], true));
        ++stk[top];
        Compress();
    }
    for (int i = 0;i < a.size();++i){
        if (a[i].second == 0)
            cout << a[i].first << " ";
        else
            dfs(a[i].first);
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'void dfs(int)':
zalmoxis.cpp:11:9: error: 'fout' was not declared in this scope
   11 |         fout << val << " ";
      |         ^~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0;i < a.size();++i){
      |                    ~~^~~~~~~~~~