Комментарии
На Edvard → Editorial of Educational Codeforces Round 3, 6 лет назад
0

A solution that use the Segment Tree implementation can be found here https://vincenzopalazzo.github.io/Competitive-Programming-and-Contests-VP-Solution/FrogsAndMosquitoes/

На diegorpc → 86D - Powerful Array (TLE), 6 лет назад
0

In my opinion, this is possible to resolve with Mo's Algorithm but C++ is not a good choice to implement an abstract solution. In some case, you need to use a big vector or Array to get store the frequency but in this case is possible to use a hash map. Unfortunately, the implementation of the C++ map is very bad. Maybe Java can be faster than C++ in this case.

Anyway, this is my solution, that uses pure Mo'a algorithm https://codeforces.me/contest/86/submission/103715846

Maybe is too late, but is good manners don't use the stringstream ss(s);

Also in the real life, the stringstream is very slow, and I agree is a little bit trick to read the input from this es.