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

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

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

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 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

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +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