Блог пользователя deam0n

Автор deam0n, 11 лет назад, По-английски

I'm trying to solve a RMQ problem at lightoj using Segment Tree , but it always gives me TLE. Can anybody help in pointing out my mistake ?

Problem link : http://www.lightoj.com/volume_showproblem.php?problem=1082

Code link : http://pastebin.com/UqaumDKG

Теги rmq
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I had the same problem many times in SPOJ. First, try replacing 'endl' by '\n'. If still TLE, try using stdio.h instead of iostream.

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks ,replacing it with stdio.h get me accepted.

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Did you notice the following:

      Note
      Dataset is huge. Use faster I/O methods.
      

      In such cases, for C++, <cstdio> is required instead of <iostream>.