# Help in spoj problem RPLN square root decomposition

here is my code i am getting SIGSEV plz help me where i am going wrong

#include<bits/stdc++.h>
using namespace std;

#define SQR 100000
#define ll long long

ll block[SQR];
ll arr[SQR];
ll b_size;

ll query(ll l,ll r)
{

``````ll ans=INT_MAX;

while(l<r && l%b_size!=0)
{
ans=min(ans,arr[l]);
l++;
}
while(l+b_size<=r)
{
ans=min(ans,block[l/b_size]);
l++;
}
while(l<=r)
{
ans=min(ans,arr[l]);
l++;
}
return ans;
``````

}

void preprocess(ll n)
{
ll b_index=-1;

``````b_size=sqrt(n);

for(ll i=0;i<b_size;i++) block[i]=INT_MAX;

for(ll i=0;i<n;i++)
{
if(i%b_size==0)
{
b_index++;
}
block[b_index]=min(block[b_index],arr[i]);
}
``````

}

int main()
{
int t;
cin>>t;

int caseCount=0;

while(t)
{
ll n,q;
cin>>n>>q;

``````   caseCount++;

for(ll i=0;i<n;i++) cin>>arr[i];

preprocess(n);

//cout<<b_size<<endl;

//for(int i=0;i<=b_size;i++) cout<<block[i]<<" ";

//cout<<endl;
printf("Scenario #%d:\n",caseCount);

while(q--)
{
ll l,r;
cin>>l>>r;
l--;
r--;
cout<<query(l,r)<<endl;

}
``````

}
return 0;
}