Skip to content

Instantly share code, notes, and snippets.

#nohup bash ./run_worker.sh $1 $2
#$1 = number of workers
#$2 = reset?
if [ "$2" == "reset" ]; then
php reset.php;
fi
for (( i = 0; i < $1; i++ )); do
php worker.php $i &
PID[$i]=$!;
//given A[0..(N-1)], compute Q queies of min(A[i..j]) in O(QlgN+NlgN)
int A[MAXN], a[MAXL][MAXN]; // MAXL = log(MAXN)+1
void buildTree()
{
for(int i = 0; i < N; i++)
a[0][i] = A[i];
L = int(log2(N))+1;
for(int k = 0; k < L; k++)
{
for(int i = 0; i < N; i++)