# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
800288 |
2023-08-01T13:06:39 Z |
hugo_pm |
Editor (BOI15_edi) |
C++17 |
|
3000 ms |
14860 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
6 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
14860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
5508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
6 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |