답안 #578607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578607 2022-06-17T11:14:55 Z FatihSolak Zalmoxis (BOI18_zalmoxis) C++17
40 / 100
183 ms 18256 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<pair<int,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(),1});
            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(),0});
        now.pop_back();
    }
    for(auto u:now){
        v.push_back({u,1});
    }
    vector<int> ans;
    int needed = n + k -  v.size();
    for(auto u:v){
        auto tmp = create(u.first,(u.second?min(1<<u.first,needed+1):1));
        for(auto c:tmp){
            ans.push_back(c);
        }
        needed -= tmp.size() - 1;
    }
    assert(ans.size() == n + k);
    for(auto u:ans){
        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
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from zalmoxis.cpp:1:
zalmoxis.cpp: In function 'void solve()':
zalmoxis.cpp:48:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     assert(ans.size() == n + k);
      |            ~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 18220 KB Output is correct
2 Correct 160 ms 18220 KB Output is correct
3 Correct 156 ms 18232 KB Output is correct
4 Correct 167 ms 18248 KB Output is correct
5 Correct 183 ms 18256 KB Output is correct
6 Correct 155 ms 18220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 18152 KB not a zalsequence
2 Correct 176 ms 18244 KB Output is correct
3 Correct 168 ms 18156 KB Output is correct
4 Incorrect 172 ms 18192 KB not a zalsequence
5 Incorrect 175 ms 18228 KB not a zalsequence
6 Incorrect 164 ms 18224 KB not a zalsequence
7 Incorrect 161 ms 18220 KB not a zalsequence
8 Incorrect 169 ms 18196 KB not a zalsequence
9 Incorrect 154 ms 17828 KB not a zalsequence
10 Incorrect 140 ms 10600 KB not a zalsequence
11 Incorrect 156 ms 16128 KB not a zalsequence
12 Incorrect 151 ms 10340 KB not a zalsequence
13 Incorrect 144 ms 10356 KB not a zalsequence
14 Incorrect 139 ms 10368 KB not a zalsequence