Need help in this problem

Revision en2, by prabalsingh24, 2019-10-03 07:08:36

This is the problem https://codeforces.com/contest/1234/problem/D I made segment tree for each alphabet (26) and calculated sum of segments. So if the query is to find distinct character in [l,r] I find sum in [l,r] in each of the 26 segment tree and answer is number of non zero segments. https://ide.codingblocks.com/s/137727 This solution is giving WA in test case#2. However when i swap the line 91 and 92. I get AC. https://ide.codingblocks.com/s/137726 The line 91 and 92 are only the update statement and they are not related to each other. If the query is to change the character in 'pos' index to 'ch', I add 1 to 'pos' index in ch segment tree and change the index at old character segment tree to 0. Why is this happening?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English prabalsingh24 2019-10-03 07:08:36 13 Tiny change: 'abet (26) segment tree and calcu' -> 'abet (26) and calcu'
en1 English prabalsingh24 2019-10-03 07:07:53 782 Initial revision (published)