Submission #983614

# Submission time Handle Problem Language Result Execution time Memory
983614 2024-05-15T19:06:03 Z Nexus Rainforest Jumps (APIO21_jumps) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll N=2e5+9,M=2e18+9,mod=1e9+7;

bool vis[N];
pair<ll,ll>p;
vector<ll>v[N];
ll a[N],n,x,y,z;
queue<pair<ll,ll>>q;

void dfs(ll nd,ll dep,ll A,ll B,ll C,ll D)
{
    if(vis[nd])return;
    vis[nd]=1;
    if(A<=nd && nd<=B)dep=0;
    if(C<=nd && nd<=D)
    {
        if(x==-1)x=dep;
        x=min(x,dep);
        vis[nd]=0;
        return;
    }
    ++dep;
    for(auto i:v[nd])
    {
        //cout<<nd<<' '<<i<<'\n';
        dfs(i,dep,A,B,C,D);
    }
    vis[nd]=0;
}

void init(int m,vector<int>h)
{
  	v.clear();
    n=m;
    for(ll i=0;i<n;++i)a[i]=h[i];
    for(ll i=0;i<n;++i)
    {
        for(ll j=i-1;j>=0;--j)
        {
            if(a[j]>a[i])
            {
                v[i].push_back(j);
                break;
            }
        }
        for(ll j=i+1;j<n;++j)
        {
            if(a[j]>a[i])
            {
                v[i].push_back(j);
                break;
            }
        }

    }
}

int minimum_jumps(int A, int B, int C, int D)
{
    x=-1;
    for(ll i=A;i<=B;++i)
    {
        dfs(i,0,A,B,C,D);
    }
    return x;
}

Compilation message

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:37:6: error: request for member 'clear' in 'v', which is of non-class type 'std::vector<long long int> [200009]'
   37 |    v.clear();
      |      ^~~~~