답안 #750471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750471 2023-05-29T14:29:55 Z MuntherCarrot Zalmoxis (BOI18_zalmoxis) C++14
65 / 100
150 ms 10644 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: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++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 10344 KB Output is correct
2 Correct 134 ms 10296 KB Output is correct
3 Correct 129 ms 10260 KB Output is correct
4 Correct 130 ms 10288 KB Output is correct
5 Correct 136 ms 10356 KB Output is correct
6 Correct 150 ms 10332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 10244 KB Output is correct
2 Correct 132 ms 10328 KB Output is correct
3 Incorrect 132 ms 10284 KB Unexpected end of file - int32 expected
4 Correct 133 ms 10348 KB Output is correct
5 Correct 131 ms 10348 KB Output is correct
6 Correct 134 ms 10352 KB Output is correct
7 Correct 129 ms 10376 KB Output is correct
8 Correct 140 ms 10388 KB Output is correct
9 Incorrect 118 ms 10644 KB Unexpected end of file - int32 expected
10 Incorrect 52 ms 5568 KB Unexpected end of file - int32 expected
11 Incorrect 83 ms 7796 KB Unexpected end of file - int32 expected
12 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected