답안 #64371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64371 2018-08-04T08:53:51 Z Talant Zalmoxis (BOI18_zalmoxis) C++17
40 / 100
478 ms 6976 KB
#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)

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);
            deque<int> d;

            while (cur > 0 && !q.empty()) {
                  int o = q.front();
                  o --;
                  q.pop_front();
                  if (o >= 0) q.push_front(o),q.push_front(o),cur --;
                  else d.pb(o + 1);
            }
            for (auto to : d)
                  cout << to << " ";
            for (auto to : q)
                  cout << to << " ";
            last = to.fr;
      }
      for (int i = last; i <= n; i ++)
            cout << a[i] << " ";
}

Compilation message

zalmoxis.cpp:24:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:50:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int i = 0; i < q.size(); i ++)
                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 6264 KB Output is correct
2 Correct 300 ms 6264 KB Output is correct
3 Correct 440 ms 6440 KB Output is correct
4 Correct 311 ms 6440 KB Output is correct
5 Correct 359 ms 6472 KB Output is correct
6 Correct 323 ms 6472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 478 ms 6588 KB Expected EOF
2 Correct 363 ms 6588 KB Output is correct
3 Correct 436 ms 6624 KB Output is correct
4 Incorrect 367 ms 6752 KB Expected EOF
5 Incorrect 333 ms 6752 KB Expected EOF
6 Incorrect 356 ms 6752 KB Expected EOF
7 Incorrect 338 ms 6752 KB Expected EOF
8 Incorrect 319 ms 6752 KB Expected EOF
9 Incorrect 348 ms 6976 KB Expected EOF
10 Incorrect 246 ms 6976 KB Expected EOF
11 Incorrect 307 ms 6976 KB Expected EOF
12 Incorrect 145 ms 6976 KB Expected EOF
13 Incorrect 125 ms 6976 KB Expected EOF
14 Incorrect 133 ms 6976 KB Expected EOF