Skip to content

Instantly share code, notes, and snippets.

View Mistuke's full-sized avatar

Tamar Christina Mistuke

View GitHub Profile
@Mistuke
Mistuke / lazy_segment_tree.cpp
Created August 16, 2017 14:15 — forked from Se7soz/lazy_segment_tree.cpp
An example for lazy segment trees.. to read full topic visit http://se7so.blogspot.com
/**
* In this code we have a very large array called arr, and very large set of operations
* Operation #1: Increment the elements within range [i, j] with value val
* Operation #2: Get max element within range [i, j]
* Build tree: build_tree(1, 0, N-1)
* Update tree: update_tree(1, 0, N-1, i, j, value)
* Query tree: query_tree(1, 0, N-1, i, j)
*/
#include<iostream>
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
module Main (main) where
import Control.Monad (when)
import qualified Data.ByteString.Lazy as BL