| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1320421 | NgTrung2217 | Editor (BOI15_edi) | C++20 | 106 ms | 28248 KiB |
#include <bits/stdc++.h>
#define taskname ""
using namespace std;
using ld = long double;
using ull = unsigned long long;
using ll = long long;
const char el = '\n';
const char sp = ' ';
const ll inf = 1e18;
const int maxN = 3e5 + 5;
const int LOG = 20;
int n, a[maxN], p[maxN][LOG], h[maxN];
int get_p(int u, int target_h)
{
if (h[u] <= target_h) return u;
for (int i = LOG - 1; i >= 0; --i)
{
if (h[p[u][i]] > target_h) u = p[u][i];
}
return p[u][0];
}
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen(taskname ".inp", "r"))
{
freopen(taskname ".inp", "r", stdin);
freopen(taskname ".out", "w", stdout);
}
if (!(cin >> n)) return 0;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
if (a[i] < 0)
{
h[i] = -a[i];
int z = get_p(i - 1, h[i] - 1);
p[i][0] = get_p(z - 1, h[i] - 1);
for (int j = 1; j < LOG; ++j)
{
p[i][j] = p[p[i][j - 1]][j - 1];
}
}
cout << a[get_p(i, 0)] << el;
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
