제출 #1113132

#제출 시각아이디문제언어결과실행 시간메모리
1113132ortsac밀림 점프 (APIO21_jumps)C++17
0 / 100
4070 ms336 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<long long, long long> #define fr first #define se second int n; vector<int> h; vector<int> l; vector<int> r; void init(int32_t N, vector<int32_t> H) { n = N; h.resize(n); for (int i = 0; i < n; i++) h[i] = H[i]; l.resize(n); r.resize(n); stack<pii> s; for (int i = 0; i < n; i++) { while (!s.empty() && (s.top().fr < h[i])) s.pop(); if (s.empty()) l[i] = -1; else l[i] = s.top().se; s.push({h[i], i}); } while (!s.empty()) s.pop(); for (int i = n - 1; i >= 0; i--) { while (!s.empty() && (s.top().fr < h[i])) s.pop(); if (s.empty()) r[i] = -1; else r[i] = s.top().se; s.push({h[i], i}); } return; } const int INF = 0x3f3f3f3f; vector<int> dist; int calc(int node) { if (node == -1) return INF; if (dist[node] != INF) return dist[node]; dist[node] = min(calc(l[node]) + 1, calc(r[node]) + 1); } int32_t minimum_jumps(int32_t A, int32_t B, int32_t C, int32_t D) { dist.clear(); dist.resize(n, INF); for (int i = C; i <= D; i++) dist[i] = 0; int ans = INF; for (int i = A; i <= B; i++) { ans = min(ans, calc(i)); } if (ans == INF) return -1; else return ans; }

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

jumps.cpp: In function 'long long int calc(long long int)':
jumps.cpp:46:53: warning: control reaches end of non-void function [-Wreturn-type]
   46 |   dist[node] = min(calc(l[node]) + 1, calc(r[node]) + 1);
      |                                       ~~~~~~~~~~~~~~^~~
#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...