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

Автор DryukAlex, 15 лет назад, По-русски

Twice I got TL with time 0.031 and 0.015 respectively. Who knows what does it mean?;)

http://acm-judge.usu.ru/status.aspx?space=1&num=1804&author=89474

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится

15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Code was the same all three times?
15 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
No, I updated it.
15 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
Most likely it is "idleness limit exceeded"
maybe you waste memory and program do nothing
15 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
In your TL solutions sometimes you write to the memory out of arrays, so behavior of the program becomes unpredictable. For example, on g++ it just crashes. On timus it works for few seconds before getting TL, so it really seems to be idleness limit exceeded. Just check your indices in code carefully or test on any reasonable large input and you will find your error. 
  • 15 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    >>Just check your indices in code carefully or test on any reasonable large input and you will find your error.
    and you can write this in top of your code:

    #define _GLIBCXX_DEBUG

    when you wrote this code, your programm returns RE when you using indices, which are out of range

    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится
      #define _GLIBCXX_DEBUG
      #include <cstdio>
      int main()
      {
      int ar[5]; int sum = 0;
      for(int i = -2; i <= 6; i++)
      {
      ar[i] = i;
      sum += ar[i];
      }
      printf("%d\n", sum);
      return 0;
      }

      It works without any errors on my g++ 4.4.5.
      The only reliable way to have runtime indices check I know is using std::vector and .at(). But it is a bit slower.