Due to the installation of a new fire alarm in ITMO server room, the system may be occasionally unavailable on the 27-th of May between 06:00 and 15:00 (UTC). ×

LogitechSellout's blog

By LogitechSellout, history, 4 weeks ago, In English,

Hi, I'm pretty new to CF and this is one of my first problems here

Problem Statement: https://codeforces.com/problemset/problem/245/H Basically you want to answer q queries, each stating the number of palidromes between two indicies of a long string

My code: https://codeforces.com/contest/245/submission/53304310

For some reason CF seems to time out, even though time complexity is alright (O(s^2+q)) which is quite odd

Could this because of my programming language? I know that java tends to be slow in these contests


4 weeks ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

IO is the bottleneck in your code. If you use buffer your output so it all gets printed at once and not in chunks, then it will pass. As an example, https://codeforces.com/contest/245/submission/53306869

I use StringBuilder to build my output which gets printed in its entirety when I call System.out.print().