제출 #960631

#제출 시각아이디문제언어결과실행 시간메모리
960631Trisanu_Das밀림 점프 (APIO21_jumps)C++17
컴파일 에러
0 ms0 KiB
#include "jumps.h" #include<bits/stdc++.h> using namespace std; int n, dp[200005]; vector<int> v; void init(int N, vector<int> H) { n = N; for(int i = 0; i < n; i++) h.push_back(H[i]); } int solve(int s, int c, int d) { if(c <= s && s <= d) return 0; if(dp[s] != -1) return dp[s]; int ret = INT_MAX; for(int i = s + 1; i < n; i++){ if(j[i] > j[s]){ ans = min(ans, 1 + solve(i, c, d)); break; } } for(int i = s - 1; i >= 0;i--){ if(h[i] > h[s]){ ans = min(ans, 1 + solve(i, c, d)); break; } } return dp[s] = ans; } int minimum_jumps(int a, int b, int c, int d) { memset(dp, -1, sizeof(dp)); int ans = INT_MAX; for(int i = a; i <= b; i++) ans = min(ans, solve(i, c, d)); if(ans == INT_MAX) ans = -1; return ans; }

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

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:10:32: error: 'h' was not declared in this scope
   10 |     for(int i = 0; i < n; i++) h.push_back(H[i]);
      |                                ^
jumps.cpp: In function 'int solve(int, int, int)':
jumps.cpp:18:12: error: 'j' was not declared in this scope
   18 |         if(j[i] > j[s]){
      |            ^
jumps.cpp:19:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |             ans = min(ans, 1 + solve(i, c, d));
      |             ^~~
      |             abs
jumps.cpp:24:12: error: 'h' was not declared in this scope
   24 |         if(h[i] > h[s]){
      |            ^
jumps.cpp:25:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |             ans = min(ans, 1 + solve(i, c, d));
      |             ^~~
      |             abs
jumps.cpp:29:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     return dp[s] = ans;
      |                    ^~~
      |                    abs
jumps.cpp:16:9: warning: unused variable 'ret' [-Wunused-variable]
   16 |     int ret = INT_MAX;
      |         ^~~