# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63026 | 2018-07-31T10:44:43 Z | hamzqq9 | Zalmoxis (BOI18_zalmoxis) | C++14 | 334 ms | 14812 KB |
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<ii,int> #define sz(x) (x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 2000500000 #define MOD 1000000007 #define N 305 #define LOG 20 using namespace std; int n,k,x; stack<int> s; vector<int> ans,cev,seq; int rem; void solve(int x) { if(x==0 || rem==0) { cev.pb(x); return ; } rem--; solve(x-1); solve(x-1); } int main() { // freopen("input.txt","r",stdin); scanf("%d %d",&n,&k); for(int i=1;i<=n+1;i++) { if(i==n+1 && sz(ans)==n+k) break ; if(i!=n+1) {scanf("%d",&x);seq.pb(x);} else x=inf; while((i!=n+1)?(sz(s) && s.top()<x):(sz(s)>1)) { int val=s.top(); ans.pb(val); while(sz(s) && s.top()==val) { s.pop(); val++; } s.push(val); } if(i!=n+1) { int tut=x; while(sz(s) && s.top()==tut) { s.pop(); tut++; } s.push(tut); ans.pb(x); } } int val=s.top(); while(val<30) { ans.pb(val); val++; } rem=n+k-sz(ans); int cur=0; for(int i=0;i<sz(ans);i++) { if(cur<sz(seq) && seq[cur]==ans[i]) { cev.pb(ans[i]); cur++; } else { solve(ans[i]); } } for(auto x:cev) printf("%d ",x); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 261 ms | 14288 KB | Output is correct |
2 | Correct | 304 ms | 14332 KB | Output is correct |
3 | Correct | 263 ms | 14672 KB | Output is correct |
4 | Correct | 226 ms | 14672 KB | Output is correct |
5 | Correct | 233 ms | 14672 KB | Output is correct |
6 | Correct | 252 ms | 14672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 215 ms | 14672 KB | Output is correct |
2 | Correct | 271 ms | 14700 KB | Output is correct |
3 | Correct | 278 ms | 14700 KB | Output is correct |
4 | Correct | 334 ms | 14700 KB | Output is correct |
5 | Correct | 260 ms | 14764 KB | Output is correct |
6 | Correct | 285 ms | 14812 KB | Output is correct |
7 | Correct | 250 ms | 14812 KB | Output is correct |
8 | Correct | 313 ms | 14812 KB | Output is correct |
9 | Correct | 245 ms | 14812 KB | Output is correct |
10 | Correct | 171 ms | 14812 KB | Output is correct |
11 | Correct | 191 ms | 14812 KB | Output is correct |
12 | Correct | 147 ms | 14812 KB | Output is correct |
13 | Correct | 181 ms | 14812 KB | Output is correct |
14 | Correct | 133 ms | 14812 KB | Output is correct |