# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127738 | 2019-07-10T04:42:34 Z | abacaba | Zalmoxis (BOI18_zalmoxis) | C++14 | 654 ms | 262148 KB |
#include <bits/stdc++.h> using namespace std; #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> const int START_VALUE = 30; const int inf = 2e9; const int N = 1e6 + 15; int n, k, a[N]; struct node { node *prev, *next; int val; node(int val) : val(val) { prev = next = NULL; } }; typedef node* pnode; map <int, vector <pnode> > is; vector <pnode> fr; pnode root, last; stack <pair <int, pnode> > st, temp; inline void processforward() { while(last && k) { int now = last->val; while(!st.empty() && st.top().f == now) { st.pop(); ++now; } while(!st.empty() && st.top().f < now) { pnode x = new node(st.top().f); x->prev = st.top().se; x->next = st.top().se->next; if(x->next) x->next->prev = x; if(x->prev) x->prev->next = x; fr.pb(x); int curval = x->val; while(!st.empty() && st.top().f == curval) st.pop(), ++curval; st.push(mp(curval, x)); --k; } while(!st.empty() && st.top().f == now) { st.pop(); ++now; } st.push(mp(now, last)); if(!last->next) break; last = last->next; } } inline void addelse() { while(!st.empty()) { int now = st.top().f; temp.push(st.top()); st.pop(); while(!st.empty() && st.top().f > now + 1) { int need = st.top().f - 1; pnode x = new node(need); x->prev = st.top().se; x->next = st.top().se->next; if(x->next) x->next->prev = x; if(x->prev) x->prev->next = x; fr.pb(x); st.push(mp(need, x)); --k; } } } inline void checkend() { st = temp; if(!st.empty() && st.top().f != START_VALUE) { last = st.top().se; pnode x = new node(st.top().f); x->prev = last; if(x->prev) x->prev->next = x; fr.pb(x); --k; } } inline void extend_added() { while(!fr.empty() && k) { pnode x = fr.back(); fr.ppb(); if(x->val <= 1) continue; pnode a = new node(x->val - 1), b = new node(x->val - 1); a->prev = x->prev; a->next = b; b->prev = a; b->next = x->next; if(b->next) b->next->prev = b; if(a->prev) a->prev->next = a; fr.pb(a); fr.pb(b); --k; } } inline void output() { while(root) { printf("%d ", root->val); root = root->next; } } int main() { scanf("%d%d", &n, &k); for(int i = 1; i <= n; ++i) scanf("%d", &a[i]); root = new node(a[1]); is[a[1]].pb(root); last = root; for(int i = 2; i <= n; ++i) { pnode x = new node(a[i]); x->prev = last; last->next = x; last = x; is[a[i]].pb(x); } last = root; processforward(); addelse(); checkend(); extend_added(); output(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 278 ms | 45420 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 229 ms | 44032 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 212 ms | 43768 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 215 ms | 43784 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 249 ms | 44700 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 279 ms | 45692 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 204 ms | 43584 KB | Unexpected end of file - int32 expected |
2 | Runtime error | 654 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Correct | 286 ms | 45564 KB | Output is correct |
4 | Incorrect | 269 ms | 45196 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 233 ms | 44316 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 267 ms | 45320 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 206 ms | 43724 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 244 ms | 44564 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 256 ms | 45980 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 208 ms | 55492 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 241 ms | 51372 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 2 ms | 376 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 2 ms | 376 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 2 ms | 256 KB | Unexpected end of file - int32 expected |