Submission #656473

#TimeUsernameProblemLanguageResultExecution timeMemory
656473MilosMilutinovicZalmoxis (BOI18_zalmoxis)C++14
35 / 100
180 ms18356 KiB
#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]; } a.push_back(30); n++; 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); } ans.pop_back(); for (auto& p : ans) { cout << p.first << " "; } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:34:11: warning: unused variable 'x' [-Wunused-variable]
   34 |       int x = stk.back();
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...