제출 #1052100

#제출 시각아이디문제언어결과실행 시간메모리
1052100PiokemonRainforest Jumps (APIO21_jumps)C++17
컴파일 에러
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; constexpr int N = 2e5; int h[N+9]; int l[N+9]; int r[N+9]; int dst[N+9]; int n; constexpr int base = (1<<18); int tree[2*base+9]; // min void sed(int x, int a, int b, int p, int k, int val){ if (p<b || k>a)return; if (p<=a && b<=k){ tree[x]=min(tree[x],val); return; } int mid=(a+b)/2; sed(2*x,a,mid,p,k,val); sed(2*x+1,mid+1,b,p,k,val); } int query(int x){ x+=base; int odp=1e9; while(x){ odp=min(odp,tree[x]); x/=2; } return odp; } void init(int N, std::vector<int> H) { n=N; for (int x=0;x<n;x++)h[x]=H[x]; for (int x=0;x<=2*base+2;x++)tree[x]=1e9; for (int x=n-1;x>=0;x--){ r[x]=query(x); sed(1,0,base-1,0,r[x],x); } for (int x=0;x<=2*base+2;x++)tree[x]=1e9; for (int x=0;x<n;x++){ l[x]=query(x); sed(1,0,base-1,0,r[x],x); } return 0; } int minimum_jumps(int A, int B, int C, int D){ vector<int> kol; for (int x=0;x<n;x++)dst[x]=1e9; for (int x=A;x<=B;x++){ dst[x]=0; kol.push_back(x); } for (int y=0;y<kol.size();y++){ if (C<=kol[y] && kol[y]<=D)return dst[kol[y]]; if (l[kol[y]]!=1e9){ if (dst[l[kol[y]]]>dst[kol[y]]+1){ dst[l[kol[y]]]=dst[kol[y]]+1; kol.push_back(l[kol[y]]); } } } return -1; }

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

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:50:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   50 |     return 0;
      |            ^
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for (int y=0;y<kol.size();y++){
      |                  ~^~~~~~~~~~~