noob084's blog

By noob084, history, 8 years ago, In English

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.

  • Vote: I like it
  • +4
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 years ago, # |
  Vote: I like it +18 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it +17 Vote: I do not like it

    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 years ago, # ^ |
    Rev. 3   Vote: I like it +7 Vote: I do not like it

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