# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335453 | 3funnn | Zalmoxis (BOI18_zalmoxis) | C++17 | 306 ms | 15560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
const int NMAX = 1000000;
int need;
void dfs(int val){
if (need == 0 || val == 0){
cout << val << " ";
return;
}
--need;
dfs(val - 1);
dfs(val - 1);
}
int stk[NMAX + 5], top;
void Compress(){
while (top >= 2 && stk[top] == stk[top - 1]){
--top;
++stk[top];
}
}
int main()
{
int N, K;
cin >> N >> K;
vector <int> v(N);
for (int i = 0;i < N;++i)
cin >> v[i];
need = K;
vector <pair <int, bool>> a;
stk[++top] = 31;
for (int i = 0;i < N;++i){
while (v[i] > stk[top]){
--need;
a.push_back(mp(stk[top], true));
++stk[top];
Compress();
}
a.push_back(mp(v[i], false));
stk[++top] = v[i];
Compress();
}
while (stk[2] != 30){
--need;
a.push_back(mp(stk[top], true));
++stk[top];
Compress();
}
for (int i = 0;i < a.size();++i){
if (a[i].second == 0)
cout << a[i].first << " ";
else
dfs(a[i].first);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |