Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

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
  • Проголосовать: не нравится

13 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
Code was the same all three times?
13 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
No, I updated it.
13 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится
Most likely it is "idleness limit exceeded"
maybe you waste memory and program do nothing
  • 13 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    Interesting. Couldn't you give me this test - I'd like to check it in my computer.
  • 13 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    The only thing that differs in TL and AC solutions is that in TL one I use an array of strings and read some of the elements for this array more than once. For example,
    ...
    string mas[5];
    void main
    {
    ...
    cin>>mas[0];
    ...
    cin>>mas[0];
    ...
    }

    Could it cause any problems?
13 лет назад, # |
  Проголосовать: нравится +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. 
  • 13 лет назад, # ^ |
      Проголосовать: нравится 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

    • 13 лет назад, # ^ |
        Проголосовать: нравится 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.
      • 13 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится
        Sorry, but how can I write to the memory out of array when I have the array of 5 elements and I call only the elements from 0 to 4?..
        The part of my code which causes problems is as follows:

        string mas[5];
        ...
        int main()
        int t;
        {
        cin>>t;
        for (int i=0;i<t;i++)
        {
        int a,b;
        bool f;
        for (int j=0;j<3;j++)
        cin>>mas[i];
        cin>>mas[3];
        if (mas[3]=="home") f=true;
        else f=false;
        cin>>mas[3]>>mas[4];
        cin>>a;
        for (int j=0;j<3;j++)
        cin>>mas[i];
        cin>>b;
        cin>>mas[0];
                        ...
        }
        return 0;
        }