Empty output

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:

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

line 24 to 30 are causing errors.([Your Solution])(Solution: 49113880 | CodeChef)
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 :slight_smile:

Indeed, and instantly revealed by compiler warnings :slight_smile:

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