Search
 
SCRIPT & CODE EXAMPLE
 

CPP

query for rmq using sqrt decomposition

int query(int l, int r)
{
  int LB = l/Blk; //Blk = block size
  int RB = r/Blk;
  int minimum = INT_MAX;
  
  if(LB == RB) {
    for(int i=l; i<=r; i++) {
      minimum = min(minimum, arr[i]);
    }
  }
  else {
    for(int i=l; i<Blk*(LB+1); i++) minimum = min(minimum, arr[i]);
    for(int i=LB+1; i<RB; i++) minimum = min(minimum, seg[i]);
    for(int i=RB*Blk; i<=r; i++) minimum = min(minimum, arr[i]);
  }
  return min;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ how to iterate through 2d array in c++ 
Cpp :: stack in c++ data structure 
Cpp :: cpp-variadics/problem? 
Cpp :: pass address to function c++ 
Cpp :: decising how many numbers after comma c++ 
Cpp :: play sound opencv video c++ 
Cpp :: niet full form 
Cpp :: std::throw_with_nested 
Cpp :: arduino jumper programmieren 
Cpp :: factorial MOD 998244353 
Cpp :: add comment in c/c++ 
Cpp :: choose endianness in cpp 
Cpp :: add nested vector cpp 
Cpp :: vector.rbegin() 
Cpp :: The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 . 
Cpp :: C++ 4.3.2 (gcc-4.3.2) sample 
Cpp :: split date and time in a column in db browser 
Cpp :: assoc-right antlr 
Cpp :: print all chrchetrs of a string c++ 
Cpp :: c++ projects 
Cpp :: c++ array on heap 
Cpp :: C++ Area and Circumference of a Circle 
Cpp :: c++ copy string 
Cpp :: c++ function with parameters 
Cpp :: why ostream cannot be constant 
C :: rename c 
C :: sstf program in c 
C :: how to find all the missing dates and increment the series in r 
C :: lsusb command not found 
C :: armstrong number using function in c 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =