답안 #578604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578604 2022-06-17T11:06:15 Z FatihSolak Zalmoxis (BOI18_zalmoxis) C++17
45 / 100
162 ms 10360 KB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
vector<int> create(int a,int b){
    if(b == 1){
        return {a};
    }
    auto l = create(a-1,b/2);
    auto r = create(a-1,b-b/2);
    for(auto u:r){
        l.push_back(u);
    }
    return l;
}
void solve(){
    int n,k;
    cin >> n >> k;
    vector<int> v;
    vector<int> now = {30};
    for(int i = 1;i<=n;i++){
        int x;
        cin >> x;
        while(now.back() < x){
            v.push_back(now.back());
            now.pop_back();
        }
        while(now.back() > x){
            int tmp = now.back()-1;
            now.pop_back();
            now.push_back(tmp);
            now.push_back(tmp);
        }
        v.push_back(now.back());
        now.pop_back();
    }
    int needed = n + k - now.size() - v.size();
    for(auto u:now){
        auto tmp = create(u,min(1<<u,needed+1));
        for(auto u:tmp){
            v.push_back(u);
        }
        needed -= min(1<<u,needed+1) - 1;
    }
    for(auto u:v){
        cout << u << " ";
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 8400 KB Output is correct
2 Correct 141 ms 8460 KB Output is correct
3 Correct 159 ms 8420 KB Output is correct
4 Correct 146 ms 8492 KB Output is correct
5 Correct 154 ms 8552 KB Output is correct
6 Correct 134 ms 8388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 154 ms 8412 KB not a zalsequence
2 Correct 152 ms 8420 KB Output is correct
3 Incorrect 145 ms 8468 KB Unexpected end of file - int32 expected
4 Incorrect 136 ms 8552 KB not a zalsequence
5 Correct 156 ms 8512 KB Output is correct
6 Correct 144 ms 8388 KB Output is correct
7 Incorrect 162 ms 8476 KB not a zalsequence
8 Incorrect 144 ms 8528 KB not a zalsequence
9 Incorrect 138 ms 8948 KB not a zalsequence
10 Incorrect 146 ms 8044 KB not a zalsequence
11 Incorrect 133 ms 10040 KB not a zalsequence
12 Incorrect 147 ms 10332 KB not a zalsequence
13 Incorrect 146 ms 10360 KB not a zalsequence
14 Incorrect 148 ms 10308 KB not a zalsequence