제출 #1052035

#제출 시각아이디문제언어결과실행 시간메모리
1052035user736482밀림 점프 (APIO21_jumps)C++17
0 / 100
4061 ms6248 KiB
#include<bits/stdc++.h> using namespace std; int lft[200007],rgt[200007]; bool czy1=1; bool odw[200007]; int n; void init(int N,vector<int>v){ n=N; stack<int>s; lft[200006]=200006; rgt[200006]=200006; //s.push(n); for(int i=0;i<n;i++){ lft[i]=200006; rgt[i]=200006; } //return; for(int i=0;i<n;i++){ if(s.empty() || v[s.top()]>v[i]) s.push(i); else{ rgt[s.top()]=i; s.pop(); i--; } } while(s.size()>0) s.pop(); for(int i=n-1;i>=0;i--){ if(s.empty() || v[s.top()]>v[i]) s.push(i); else{ czy1=0; lft[s.top()]=i; s.pop(); i++; } } //for(int i=0;i<n;i++) //cout<<lft[i]<<" "<<rgt[i]<<"\n"; } int minimum_jumps(int a,int b,int c,int d){ //if(czy1) // return c-b; odw[200006]=1; int ans[n]; for(int i=0;i<n;i++){ odw[i]=0; ans[i]=200007;} for(int i=a;i<=b;i++) odw[i]=1; priority_queue<pair<int,int>>pq; for(int i=a;i<=b;i++){ pq.push({0,i}); } while(!pq.empty()){ pair<int,int>pom=pq.top(); pq.pop(); ans[pom.second]=pom.first; if(!odw[lft[pom.second]]){ odw[lft[pom.second]]=1; pq.push({pom.first+1,lft[pom.second]}); } if(!odw[rgt[pom.second]]){ odw[rgt[pom.second]]=1; pq.push({pom.first+1,rgt[pom.second]}); } //return 0; } int mn=200007; for(int i=c;i<=d;i++){ mn=min(mn,ans[i]); } if(mn==200007) mn=-1; return mn; }
#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...