답안 #668181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668181 2022-12-03T08:11:35 Z MrDeboo Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
164 ms 19020 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    deque<int>a,b(n);
    for(auto &i:b)cin>>i;
    deque<int>doq=b;
    deque<int>dq={b[0]};
    a.push_back(b[0]);
    b.pop_front();
    while(b.size()){
        if(b[0]<=a.back()){
            a.push_back(b[0]);
            dq.push_back(b[0]);
            b.pop_front();
        }else{
            k--;
            a.push_back(a.back());
            dq.push_back(a.back());
        }
        while(a.size()>1&&a.back()==a[a.size()-2]){
            int A=a.back();
            a.pop_back();
            a.pop_back();
            a.push_back(A+1);
        }
    }
    while(a.size()>1){
        a.push_back(a.back());
        dq.push_back(a.back());
        k--;
        while(a.size()>1&&a.back()==a[a.size()-2]){
            int A=a.back();
            a.pop_back();
            a.pop_back();
            a.push_back(A+1);
        }
    }
    assert(k>=0);
    int g=a.back();
    while(k--){
        dq.push_back(g++);
    }
    int f=0;
    for(int i=0;i<dq.size();i++){
        if(f<doq.size()&&doq[f]==dq[i])f++;
    }
    deque<int>deq;
    for(int i=0;i<dq.size();i++){
        deq.push_back(dq[i]);
        while(deq.size()>1&&deq.back()==deq[deq.size()-2]){
            int a=deq.back();
            deq.pop_back();
            deq.pop_back();
            deq.push_back(a+1);
        }
    }
    assert(deq.size()==1);
    for(auto &i:dq)cout<<i<<' ';
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:53:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<dq.size();i++){
      |                 ~^~~~~~~~~~
zalmoxis.cpp:54:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         if(f<doq.size()&&doq[f]==dq[i])f++;
      |            ~^~~~~~~~~~~
zalmoxis.cpp:57:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<dq.size();i++){
      |                 ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 18988 KB Output is correct
2 Correct 158 ms 19004 KB Output is correct
3 Correct 159 ms 18984 KB Output is correct
4 Correct 157 ms 18944 KB Output is correct
5 Correct 159 ms 18988 KB Output is correct
6 Correct 158 ms 19004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 161 ms 18948 KB not a zalsequence
2 Correct 161 ms 18960 KB Output is correct
3 Incorrect 156 ms 19012 KB not a zalsequence
4 Incorrect 157 ms 19016 KB not a zalsequence
5 Incorrect 164 ms 19020 KB not a zalsequence
6 Incorrect 160 ms 18988 KB not a zalsequence
7 Incorrect 154 ms 18988 KB not a zalsequence
8 Incorrect 163 ms 18984 KB not a zalsequence
9 Incorrect 151 ms 17496 KB not a zalsequence
10 Incorrect 111 ms 15752 KB not a zalsequence
11 Incorrect 129 ms 16220 KB not a zalsequence
12 Incorrect 84 ms 15444 KB not a zalsequence
13 Incorrect 89 ms 15396 KB not a zalsequence
14 Incorrect 87 ms 15320 KB not a zalsequence