답안 #909794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909794 2024-01-17T12:27:32 Z 8pete8 Zalmoxis (BOI18_zalmoxis) C++17
30 / 100
1000 ms 45972 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<float.h>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,ll>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
using namespace std;
#define int long long
#define double long double
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
const int mod=1e9+7,mxn=3e5,lg=30,inf=1e18,minf=-1e9,Mxn=100000;
int n,m;
int32_t main(){
    fastio
    cin>>n>>m;
    vector<int>v(n),ans;
    for(int i=0;i<n;i++)cin>>v[i];
    deque<int>dq;
    dq.pb(30);
    for(int i=0;i<n;i++){
        while(!dq.empty()&&dq.front()<v[i]){
            ans.pb(dq.front());
            dq.pop_front();
        }
        int k=dq.front();
        dq.pop_front();
        for(int j=k;j>v[i];j--)dq.push_front(j-1);
        ans.pb(v[i]);
    }
    while(!dq.empty()){
        ans.pb(dq.front());
        dq.pop_front();
    }
    int cur=0,tmp=0;
    for(int i=0;i<ans.size();i++){
        if(cur<n&&v[cur]==ans[i]){
            cur++;
            cout<<ans[i]<<" ";
            continue;
        }
        stack<int>st;
        st.push(ans[i]);
        while(!st.empty()&&st.size()<m){
            while(!st.empty()&&st.top()==0){
                cout<<0<<" ";
                m--;
                st.pop();
            }
            if(st.empty())break;
            tmp=st.top();
            st.pop();
            st.push(tmp-1);
            st.push(tmp-1);
        }
        m-=st.size();
        while(!st.empty()){
            cout<<st.top()<<" ";
            st.pop();
        }
    }
}

Compilation message

zalmoxis.cpp: In function 'int32_t main()':
zalmoxis.cpp:61:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
zalmoxis.cpp:69:37: warning: comparison of integer expressions of different signedness: 'std::stack<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   69 |         while(!st.empty()&&st.size()<m){
      |                            ~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 18164 KB Output is correct
2 Correct 148 ms 18656 KB Output is correct
3 Correct 107 ms 18192 KB Output is correct
4 Correct 109 ms 18252 KB Output is correct
5 Correct 103 ms 18288 KB Output is correct
6 Correct 131 ms 18316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 371 ms 25584 KB Expected EOF
2 Incorrect 201 ms 20444 KB Expected EOF
3 Incorrect 184 ms 21016 KB Expected EOF
4 Incorrect 591 ms 34416 KB Expected EOF
5 Incorrect 189 ms 20920 KB Expected EOF
6 Incorrect 275 ms 23552 KB Expected EOF
7 Incorrect 387 ms 27276 KB Expected EOF
8 Incorrect 106 ms 18204 KB Expected EOF
9 Execution timed out 1065 ms 45972 KB Time limit exceeded
10 Execution timed out 1062 ms 39860 KB Time limit exceeded
11 Execution timed out 1018 ms 41832 KB Time limit exceeded
12 Execution timed out 1054 ms 35912 KB Time limit exceeded
13 Execution timed out 1014 ms 34224 KB Time limit exceeded
14 Execution timed out 1082 ms 35496 KB Time limit exceeded