Author’s Solution can be found here
Any similar problems for practice?
@karan173 There are many problems which can be solved using the “trick” for offline queries as described in the editorial. Some of them are:
Chef and Substrings : http://www.codechef.com/COOK41/problems/GERALD3
Tree and Queries : http://codeforces.com/contest/375/problem/D
Jeff and Removing Periods : http://codeforces.com/contest/351/problem/D
Thanks for replying and for the great editorial! Will look at the problems!
Thanks for the editorial, I have come across a similar question on hacker earth with stricter constraints :
the author’s solution gives SIGSEGV even after changing chunk vector size (1000) , editorial on hackerearth seems to do something different with 2 fenwick trees any help on explaining hacker earth approach or modifying author’s solution to pass it on hacker earth will be much appreciated