Submission #1052092

#TimeUsernameProblemLanguageResultExecution timeMemory
1052092Piokemon밀림 점프 (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#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, 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;
}

Compilation message (stderr)

jumps.cpp:36:24: error: expected ',' or '...' before 'H'
   36 | void init(int N, int[] H){
      |                        ^
jumps.cpp: In function 'void init(int, int*)':
jumps.cpp:38:31: error: 'H' was not declared in this scope
   38 |     for (int x=0;x<n;x++)h[x]=H[x];
      |                               ^
jumps.cpp:49:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   49 |     return 0;
      |            ^
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int y=0;y<kol.size();y++){
      |                  ~^~~~~~~~~~~