Submission #750470

# Submission time Handle Problem Language Result Execution time Memory
750470 2023-05-29T14:29:22 Z MuntherCarrot Zalmoxis (BOI18_zalmoxis) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int long long
#define endl '\n'
#define all(x) x.begin(),x.end()
const ll MOD = 1e9 + 7, SZ = 1e5 + 10, INF = 1e18;
int n, k, sz;
void solve(int x){
    if(sz == n + k || x == 0){
        cout << x << ' ';
        return;
    }
    sz++;
    solve(x - 1);
    solve(x - 1);
}
vector<int> vec, s, ans;
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    int arr[n];
    for(int &i : arr)
        cin >> i;
    //--//
    int idx = 1;
    s.push_back(arr[0]);
    ans.push_back(arr[0]);
    while(s.back() != 30){
        // cout << s.back() << endl;
        if(idx == n){
            ans.push_back(s.back());
            vec.push_back(ans.size() - 1);
            s.push_back(s.back());

            while(s.size() > 1 && (s[s.size() - 1] == s[s.size() - 2] || s[s.size() - 1] < 0)){
                // cout << idx << ' ' << s[s.size() - 1] << ' ' <<  s[s.size() - 2] << endl;
                s.pop_back();
                s.back()++;
            }
            continue;
        }
        if(arr[idx] > s.back()){
            ans.push_back(s.back());
            vec.push_back(ans.size() - 1);
            s.push_back(s.back());
        }
        else{
            ans.push_back(arr[idx]);
            s.push_back(arr[idx]);
            idx++;

        }
        while(s.size() > 1 && (s[s.size() - 1] == s[s.size() - 2]){
            // cout << idx << ' ' << s[s.size() - 1] << ' ' <<  s[s.size() - 2] << endl;
            s.pop_back();
            s.back()++;
        }
    }
    reverse(all(vec));
    sz = ans.size();
    for(int i=0;i<ans.size();i++){
        if(vec.back() == i)
            solve(ans[i]);
        else
            cout << ans[i] << ' ';
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int32_t main()':
zalmoxis.cpp:54:67: error: expected ')' before '{' token
   54 |         while(s.size() > 1 && (s[s.size() - 1] == s[s.size() - 2]){
      |              ~                                                    ^
      |                                                                   )
zalmoxis.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~