Submission #1085299

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10852992024-09-07 22:04:02veehjRailway Trip (JOI17_railway_trip)C++17
100 / 100
419 ms55896 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll)a.size()
#define all(x) (x).begin(), (x).end()
int main() {
ll n, k, q; cin >> n >> k >> q;
vector<ll> lvl(n); for(auto& u : lvl) cin >> u;
vector<vector<vector<ll>>> stp(2, vector<vector<ll>>(n, vector<ll>(18, 0LL))); //v[left/right][place][2^?]=first point place will reach
stack<ll> st;
for(ll i=0; i<n; i++){
while(!st.empty() && lvl[st.top()]<lvl[i]) st.pop();
if(st.empty()) stp[0][i][0]=i;
else stp[0][i][0]=st.top();
st.push(i);
}
while(!st.empty()) st.pop();
for(ll i=n-1; i>=0; i--){
while(!st.empty() && lvl[st.top()]<lvl[i]) st.pop();
if(st.empty()) stp[1][i][0]=i;
else stp[1][i][0]=st.top();
st.push(i);
}
for(int i=1; i<=17; i++){
for(ll j=0; j<n; j++){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...