Submission #750479

# Submission time Handle Problem Language Result Execution time Memory
750479 2023-05-29T14:44:32 Z MuntherCarrot Zalmoxis (BOI18_zalmoxis) C++14
100 / 100
138 ms 10624 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){
        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.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])){
            s.pop_back();
            s.back()++;
        }
    }
    reverse(all(vec));
    sz = ans.size();
    for(int i=0;i<ans.size();i++){
        if(vec.size() && vec.back() == i){
            vec.pop_back();
            solve(ans[i]);
        }
        else
            cout << ans[i] << ' ';
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int32_t main()':
zalmoxis.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 128 ms 10348 KB Output is correct
2 Correct 138 ms 10368 KB Output is correct
3 Correct 130 ms 10352 KB Output is correct
4 Correct 133 ms 10348 KB Output is correct
5 Correct 131 ms 10324 KB Output is correct
6 Correct 136 ms 10248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 10328 KB Output is correct
2 Correct 133 ms 10340 KB Output is correct
3 Correct 129 ms 10328 KB Output is correct
4 Correct 127 ms 10296 KB Output is correct
5 Correct 129 ms 10336 KB Output is correct
6 Correct 136 ms 10336 KB Output is correct
7 Correct 124 ms 10332 KB Output is correct
8 Correct 128 ms 10360 KB Output is correct
9 Correct 122 ms 10624 KB Output is correct
10 Correct 95 ms 6768 KB Output is correct
11 Correct 107 ms 8508 KB Output is correct
12 Correct 76 ms 2192 KB Output is correct
13 Correct 78 ms 2252 KB Output is correct
14 Correct 75 ms 2244 KB Output is correct