I'm trying to solve this porlbem,where you are interested the number of distinct elements in the subsequences.
I remember it was discussed,on codeforces but can't find it(not working "search by tag"),also I was looking in the Internet,but without result.please help me and discuss again or give me the links where already discussed. thank you in advance.
https://www.google.com/search?client=opera&q=SPOJ+D-query&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#channel=suggest&q=codeforces+SPOJ+D-query
sps