Submission #555498

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5554982022-05-01 05:53:24joelauRainforest Jumps (APIO21_jumps)C++14
27 / 100
1102 ms55240 KiB
#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
int n, p1[200005][20], p2[200005][20], X[200005], spt[20][200005];
vector<int> lst[200005];
stack<int> s;
void init(int N, std::vector<int> H) {
n = N;
for (int i = 0; i < N; ++i) X[i] = H[i];
for (int i = 0; i < N; ++i) spt[0][i] = i;
for (int i = 1; i < 20; ++i) for (int j = 0; j < N; ++j) {
spt[i][j] = spt[i-1][j];
if (j+(1<<(i-1)) < N && H[spt[i-1][j+(1<<(i-1))]] < H[spt[i-1][j]]) spt[i][j] = spt[i-1][j+(1<<(i-1))];
}
memset(p1,-1,sizeof(p1));
memset(p2,-1,sizeof(p2));
for (int i = 0; i < N; ++i) {
while (!s.empty() && H[i] >= H[s.top()]) s.pop();
if (!s.empty()) p1[i][0] = s.top();
s.push(i);
}
while (!s.empty()) s.pop();
for (int i = N-1; i >= 0; --i) {
while (!s.empty() && H[i] >= H[s.top()]) s.pop();
if (!s.empty()) p2[i][0] = s.top();
s.push(i);
}
for (int i = 0; i < N; ++i) if (p1[i][0] == -1 || (p1[i][0] != -1 && p2[i][0] != -1 && H[p1[i][0]] < H[p2[i][0]])) swap(p1[i][0], p2[i][0]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...