제출 #800288

#제출 시각아이디문제언어결과실행 시간메모리
800288hugo_pmEditor (BOI15_edi)C++17
0 / 100
3070 ms14860 KiB
#include <bits/stdc++.h> #define int long long using namespace std; #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, a, b) for(int i = (a); i < (b); i++) #define sz(v) ((int)((v).size())) template<typename T> void chmax(T &x, const T &v) { if (x < v) x = v; } template<typename T> void chmin(T &x, const T &v) { if (x > v) x = v; } using pii = pair<int, int>; using vi = vector<int>; string to_string(string s) { return s; } template <typename T> string to_string(T v) { bool first = true; string res = "["; for (const auto &x : v) { if (!first) res += ", "; first = false; res += to_string(x); } res += "]"; return res; } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } void dbg_out() { cout << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> level(N, 0), value(N, -1); vector<bool> active(N, false); vector<int> parent(N, -1); for (int iOp = 0; iOp < N; ++iOp) { int action; cin >> action; if (action < 0) { level[iOp] = -action; parent[iOp] = iOp-1; while (!active[parent[iOp]] || level[parent[iOp]] >= level[iOp]) { --parent[iOp]; } } else { level[iOp] = 0, value[iOp] = action; } int flipping = iOp; while (flipping != -1) { active[flipping].flip(); flipping = parent[flipping]; } int lastEdit = iOp; while (!active[lastEdit] || level[lastEdit] != 0) { --lastEdit; } cout << value[lastEdit] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...