# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
800339 |
2023-08-01T13:29:15 Z |
hugo_pm |
Editor (BOI15_edi) |
C++17 |
|
3000 ms |
10804 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+1, 0), value(N+1, -1);
vector<bool> active(N+1, false);
vector<int> parent(N+1, -1);
// edit 0 au début
level[0] = 0, value[0] = 0, active[0] = true;
for (int iOp = 1; 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 |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
6 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
23 ms |
456 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
721 ms |
10804 KB |
Output is correct |
2 |
Correct |
795 ms |
10772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3061 ms |
5540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
6 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
23 ms |
456 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
721 ms |
10804 KB |
Output is correct |
11 |
Correct |
795 ms |
10772 KB |
Output is correct |
12 |
Execution timed out |
3061 ms |
5540 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |