please find my mistake because i am using cout in my code even though it will not print any thing on screen
this was the code:
https://www.codechef.com/viewsolution/49112353
Where are you reading the values of N and Q?
1 Like
now again i am getting that wrong answer even thought i get correct output at customs inputs
https://www.codechef.com/viewsolution/49113880
line 24 to 30 are causing errors.([Your Solution])(CodeChef: Practical coding for everyone)
There, i should be changed to a[i], as you want to know whether the element at that index is odd or even.
Also you should iterate from (l - 1) to (r - 1) & not from l to r otherwise you may get a Runtime-Error.
Maybe after all this, your solution may get TLE, in that case, learn the concept of Prefix Sum.
Thank You
Indeed, and instantly revealed by compiler warnings
[simon@simon-laptop][08:23:05]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling virenvariya-ETUP.cpp
+ g++ -std=c++14 virenvariya-ETUP.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv -fno-sanitize-recover
virenvariya-ETUP.cpp: In function βint main()β:
virenvariya-ETUP.cpp:13:13: warning: βnβ may be used uninitialized in this function [-Wmaybe-uninitialized]
int a[n];
^
virenvariya-ETUP.cpp:18:19: warning: βqβ may be used uninitialized in this function [-Wmaybe-uninitialized]
for(int i=1;i<=q;i++)
~^~~
+ set +x
Successful