제출 #657668

#제출 시각아이디문제언어결과실행 시간메모리
657668activedeltorre밀림 점프 (APIO21_jumps)C++14
33 / 100
4030 ms14460 KiB
#include "jumps.h" #include <iostream> #include <vector> #include <stack> #include <queue> using namespace std; stack <int>st; int v[200005]; vector<int>adj[200005]; int n; void init(int N, vector<int> H) { int i; n=N; for(i=1; i<=n; i++) { v[i]=H[i-1]; } v[0]=1e8; st.push(0); for(i=1; i<=n; i++) { while(v[i]>v[st.top()]) { adj[st.top()].push_back(i); st.pop(); } st.push(i); } while(st.size()) { st.pop(); } st.push(n+1); v[n+1]=1e8; for(i=n; i>=1; i--) { while(v[i]>v[st.top()]) { adj[st.top()].push_back(i); st.pop(); } st.push(i); } while(st.size()) { st.pop(); } } queue<int>qu; int rasp[200005]; int minimum_jumps(int a, int b, int c, int d) { int i,k,curr; a++; b++; c++; d++; for(i=1;i<=n;i++) { rasp[i]=1e8; } if(a>b) { swap(a,b); } if(c>d) { swap(c,d); } for(i=a;i<=b;i++) { qu.push(i); rasp[i]=0; } while(qu.size()) { curr=qu.front(); qu.pop(); if(curr>=c && curr<=d) { while(qu.size()) { qu.pop(); } return rasp[curr]; } for(i=0;i<adj[curr].size();i++) { k=adj[curr][i]; if(rasp[k]>rasp[curr]+1) { rasp[k]=rasp[curr]+1; qu.push(k); } } } return -1; } vector<int>vect; /*int main () { int ne,i,q,a,b,c,d,x; cin>>ne; for(i=1;i<=ne;i++) { cin>>x; vect.push_back(x); } init(ne,vect); cin>>q; for(i=1;i<=q;i++) { cin>>a>>b>>c>>d; cout<<minimum_jumps(a,b,c,d); } } */

컴파일 시 표준 에러 (stderr) 메시지

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:89:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         for(i=0;i<adj[curr].size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
#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...