답안 #656471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656471 2022-11-07T14:55:40 Z MilosMilutinovic Zalmoxis (BOI18_zalmoxis) C++14
5 / 100
167 ms 16420 KB
#include <bits/stdc++.h>

using namespace std;

void Push(vector<int>& v) {
  while (v.size() >= 2) {
    int sz = (int) v.size();
    if (v[sz - 1] == v[sz - 2]) {
      int x = v[sz - 1];
      v.pop_back();
      v.pop_back();
      v.push_back(x + 1);
    } else {
      break;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> stk;
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    while (!stk.empty() && stk.back() < a[i]) {
      int x = stk.back();
      ans.emplace_back(stk.back(), 1);
      stk.push_back(stk.back());
      Push(stk);
    }
    ans.emplace_back(a[i], 0);
    stk.push_back(a[i]);
    Push(stk);
  }
  for (auto& p : ans) {
    cout << p.first << " ";
  }
  return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:32:11: warning: unused variable 'x' [-Wunused-variable]
   32 |       int x = stk.back();
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 135 ms 16348 KB Unexpected end of file - int32 expected
2 Incorrect 137 ms 16228 KB Unexpected end of file - int32 expected
3 Incorrect 128 ms 16280 KB Unexpected end of file - int32 expected
4 Incorrect 141 ms 16344 KB Unexpected end of file - int32 expected
5 Incorrect 126 ms 16260 KB Unexpected end of file - int32 expected
6 Incorrect 139 ms 16224 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 16228 KB Unexpected end of file - int32 expected
2 Correct 143 ms 16336 KB Output is correct
3 Incorrect 125 ms 16344 KB Unexpected end of file - int32 expected
4 Incorrect 151 ms 16320 KB Unexpected end of file - int32 expected
5 Incorrect 129 ms 16260 KB Unexpected end of file - int32 expected
6 Incorrect 124 ms 16248 KB Unexpected end of file - int32 expected
7 Incorrect 167 ms 16304 KB Unexpected end of file - int32 expected
8 Incorrect 130 ms 16420 KB Unexpected end of file - int32 expected
9 Incorrect 153 ms 14440 KB Unexpected end of file - int32 expected
10 Incorrect 51 ms 6540 KB Unexpected end of file - int32 expected
11 Incorrect 98 ms 11592 KB Unexpected end of file - int32 expected
12 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected