제출 #967509

#제출 시각아이디문제언어결과실행 시간메모리
967509kwongweng밀림 점프 (APIO21_jumps)C++17
33 / 100
4088 ms17456 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef vector<vector<ll>> vll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define pb push_back #define ms memset #define fi first #define se second const int mxn = 2e5; int n; vi a, g[mxn]; void init(int N, vi H) { n=N; a=H; vi lf(n); vi rg(n); stack<int> S; FOR(i,0,n){ while (!S.empty() && a[S.top()] < a[i]){ S.pop(); } if (S.empty()) lf[i] = -1; else lf[i] = S.top(); S.push(i); } while (!S.empty()) S.pop(); ROF(i,n-1,0){ while (!S.empty() && a[S.top()] < a[i]){ S.pop(); } if (S.empty()) rg[i] = n; else rg[i] = S.top(); S.push(i); } FOR(i,0,n){ if (lf[i] != -1){ g[lf[i]].pb(i); } if (rg[i] != n){ g[rg[i]].pb(i); } } } int minimum_jumps(int A, int B, int C, int D) { vi bfs, used(n), dist(n); FOR(i,C,D+1){ bfs.pb(i); used[i]=1; } FOR(i,0,bfs.size()){ int u = bfs[i]; for (int v : g[u]){ if (used[v]) continue; used[v]=1; dist[v] = dist[u]+1; bfs.pb(v); } } int ans = n; FOR(i,A,B+1){ if (dist[i]) ans = min(ans, dist[i]); } if (ans==n) ans=-1; return ans; }

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

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   56 |   FOR(i,0,bfs.size()){
      |       ~~~~~~~~~~~~~~                   
jumps.cpp:56:3: note: in expansion of macro 'FOR'
   56 |   FOR(i,0,bfs.size()){
      |   ^~~
#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...