https://codeforces.com/contest/369/problem/E
Please share a segment tree code for this. and kindly explain a bit. thanks in advance
https://codeforces.com/contest/369/problem/E
Please share a segment tree code for this. and kindly explain a bit. thanks in advance
Hi @utkarsh.lal9430310535
sorry for the late reply.
u can refer to dis solution
in this we r basically doing this in every query,
let query= 1 4 7 i.e find segment with either 1,4,or 7.
in the code, we are basically finding those segments which starts and end from
thanks got it. But I tried using a seg tree to do +1 on each point and then for every given seg range I tried to find the sum, if it’s positive then some point lies inside it. but this gave TLE. I even tried BIT for optimization but again the same result . What is the difference in time complexity of our code can you tell? Thank you in advance.
can u pls share ur code.
in dis part of ur code
while(m–){
int q;
cin>>q;
int x[q];
for(int i=0;i<q;i++){
cin>>x[i];
modify(x[i],+1);
}
m and q are of range 10^5 hence O(m*q) complexity will give tle.