답안 #64368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64368 2018-08-04T08:45:28 Z Talant Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
480 ms 19188 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)
#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] << " ";

}

Compilation message

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 ++)
                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 10232 KB Output is correct
2 Correct 313 ms 10360 KB Output is correct
3 Correct 330 ms 10360 KB Output is correct
4 Correct 352 ms 10460 KB Output is correct
5 Correct 446 ms 10460 KB Output is correct
6 Correct 413 ms 10460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 456 ms 10584 KB Unexpected end of file - int32 expected
2 Correct 441 ms 10744 KB Output is correct
3 Runtime error 332 ms 16536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 431 ms 18596 KB Unexpected end of file - int32 expected
5 Incorrect 391 ms 18684 KB Unexpected end of file - int32 expected
6 Incorrect 392 ms 18708 KB Unexpected end of file - int32 expected
7 Incorrect 368 ms 18708 KB Unexpected end of file - int32 expected
8 Incorrect 480 ms 18740 KB Unexpected end of file - int32 expected
9 Incorrect 401 ms 19188 KB Unexpected end of file - int32 expected
10 Incorrect 187 ms 19188 KB Unexpected end of file - int32 expected
11 Incorrect 253 ms 19188 KB Unexpected end of file - int32 expected
12 Runtime error 13 ms 19188 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 12 ms 19188 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 11 ms 19188 KB Execution killed with signal 11 (could be triggered by violating memory limits)