# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44634 | RayaBurong25_1 | Editor (BOI15_edi) | C++17 | 203 ms | 37864 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <map>
typedef struct node node;
struct node
{
std::map<std::pair<int, int>, int> last;
};
node N[300005];
int P[300005];
int main()
{
int n;
scanf("%d", &n);
int i, x;
std::map<std::pair<int, int>, int>::iterator it;
P[0] = 0;
for (i = 1; i <= n; i++)
{
scanf("%d", &x);
if (x > 0)
{
P[i] = x;
N[x].last[{0, -i}] = P[i - 1];
printf("%d\n", x);
}
else
{
it = N[P[i - 1]].last.lower_bound({x + 1, -i});
P[i] = it->second;
N[it->second].last[{x, -i}] = P[i - 1];
printf("%d\n", it->second);
}
}
}
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... |