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

Автор noob084, история, 8 лет назад, По-английски

Here is the link of the problem : http://lightoj.com/volume_showproblem.php?problem=1135 link of code: https://ideone.com/h3Zu5C

Getting Runtime Error(RTE). Also in this problem: https://www.codechef.com/problems/MULTQ3

Can anyone help? Why getting RTE? Thanks in advance.

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

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

I can't open the lightoj problem but acc. to the codechef problem, you are not given the number of test cases. So, just removing that makes the program run successfully. ideone

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

it seems that the RTE is basically because of array accessing out of bounds

first silly mistake is tree[Max*5], notice that #define MAX 100000+10, so this is equivalent to tree[100000+10*5] which is 100050 which is not enough.

yet, your code gives RTE you have to add a small condition in your update_node() function see this code here

however, your code gives now TLE. revisit your code. i added a tiny optimization and it passed within 0.13 you can see the code here i added comments where the changes are made.

BTW, to locally test your program i think it's easier to use

while(scanf("%d %d",&n,&q) != EOF) as in this way you don't have to comment anything before submitting

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

    fu**nny story, resubmitting the two above codes gives TLE sometimes and AC sometimes. i don't know what's wrong maybe it's because of the stupid judge :3 try submitting using c++14. i'm talking about CodeChef. both submissions seem fine with LightOJ.**

  • »
    »
    8 лет назад, # ^ |
    Rev. 3   Проголосовать: нравится +7 Проголосовать: не нравится

    Thanks a lot! Finally getting AC in lightoj and codechef.