이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define int long long
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)2e6 + 7;
int n,k;
int a[N];
int ind = 1;
deque <int> q;
vector <pair<int,int> > vec;
main () {
cin >> n >> k;
for (int i = 1; i <= n; i ++)
cin >> a[i];
q.pb(30);
while (ind <= n) {
if (q.front() == a[ind]) {
q.pop_front();
ind ++;
}
else {
if (q.front() > a[ind]) {
int o = q.front();
o --;
q.pop_front();
if (o >= 0) q.push_front(o),q.push_front(o);
}
else {
vec.pb(mk(ind,q.front()));
q.pop_front();
}
}
}
for (int i = 0; i < q.size(); i ++)
vec.pb(mk(ind ++,q[i]));
int cur = k - (int)vec.size();
int last = 1;
for (auto to : vec) {
for (int i = last; i < to.fr; i ++) {
cout << a[i] << " ";
}
q.clear();
q.push_back(to.sc);
while (cur > 0) {
int o = q.front();
o --;
q.pop_front();
if (o >= 0) q.push_front(o),q.push_front(o),cur --;
}
for (auto to : q)
cout << to << " ";
last = to.fr;
}
for (int i = last; i <= n; i ++)
cout << a[i] << " ";
}
컴파일 시 표준 에러 (stderr) 메시지
zalmoxis.cpp:25:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:51:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < q.size(); i ++)
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |