# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335279 | Plurm | Railway Trip (JOI17_railway_trip) | C++11 | 2086 ms | 12524 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 <bits/stdc++.h>
using namespace std;
vector<int> g[100005]; // cartesian-tree-like graph
int d[100005];
vector<int> bckt[100005];
int l[100005];
int n,k,q;
void compute(int a){
d[a] = 0;
for(int i = 1; i <= k; i++){
for(int x : bckt[i]){
for(int y : g[x]) d[x] = min(d[x], d[y]+1);
}
reverse(bckt[i].begin(), bckt[i].end());
for(int x : bckt[i]){
for(int y : g[x]) d[x] = min(d[x], d[y]+1);
}
reverse(bckt[i].begin(), bckt[i].end());
}
}
int main(){
scanf("%d%d%d",&n,&k,&q);
stack<int> stk;
for(int i = 1; i <= n; i++){
scanf("%d", l+i);
bckt[l[i]].push_back(i);
while(!stk.empty() && l[stk.top()] <= l[i]){
g[i].push_back(stk.top());
stk.pop();
}
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... |