Submission #426063

#TimeUsernameProblemLanguageResultExecution timeMemory
426063OzyRainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl #define MAX 2000 #define izq first #define der second lli n,offset,grande,prim; lli arr[MAX+2],st[4*MAX]; pair<lli,lli> lados[MAX+2]; lli busca(lli pos, lli l, lli r, lli ini, lli fin, lli val, lli tipo) { if (ini > fin) return -1; if (ini > r || fin < l) return -1; if (st[pos] < val) return -1; if (ini == fin) return ini; lli mitad = (ini+fin)/2; if (tipo == 1) { lli a = busca(pos*2, l, r, ini, mitad, val, tipo); if (a == -1) return busca((pos*2)+1, l, r, mitad+1, fin, val, tipo); else return a; } else { lli a = busca((pos*2)+1, l, r, mitad+1, fin, val, tipo); if (a == -1) return busca(pos*2, l, r, ini, mitad, val, tipo); else return a; } } lli query(lli pos, lli l, lli r, lli ini, lli fin) { if (l > fin || r < ini) return -1; if (l <= ini && fin <= r) return st[pos]; mitad=(ini+fin)/2; return max(query(pos*2, l,r, ini, mitad), query((pos*2)+1, l, r, mitad+1, fin)); } void init(int N, std::vector<int> H) { n = N; rep(i,0,n-1) arr[i] = H[i]; offset = 1; while (offset < n) offset *= 2; rep(i,0,n-1) st[offset+i] = arr[i]; repa(i,offset-1,1) st[i] = max(st[i*2], st[(i*2)+1]); rep(i,0,n-1) { lados[i].izq = busca(1,0,i-1,0,offset-1,arr[i],0); lados[i].der = busca(1,i+1,offset-1,0,offset-1,arr[i],1); } } int minimum_jumps(int A, int B, int C, int D) { //grande = query(1,C,D,0,offset-1); //prim = busca(1,A,B, 0, offset-1, grande, 0); //if (prim == B) return C-A; }

Compilation message (stderr)

jumps.cpp: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
jumps.cpp:43:5: error: 'mitad' was not declared in this scope
   43 |     mitad=(ini+fin)/2;
      |     ^~~~~