Https://www.codechef.com/viewsolution/38032794

https://www.codechef.com/viewsolution/38032794

If i am giving test cases individually then the output i am getting is right (for number of test cases =1)…but when the test cases number are higher…my result is getting wrong.

Help!!

[simon@simon-laptop][12:25:57]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling roverboy774-STACKS.cpp
+ g++ -std=c++14 roverboy774-STACKS.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
roverboy774-STACKS.cpp: In function ‘void bs(std::__debug::vector<long long int>&, long long int)’:
roverboy774-STACKS.cpp:9:29: warning: conversion to ‘int’ from ‘std::__cxx1998::vector<long long int, std::allocator<long long int> >::size_type {aka long unsigned int}’ may alter its value [-Wconversion]
     int start=0,end=v.size()-1;
                     ~~~~~~~~^~
roverboy774-STACKS.cpp:16:10: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
          else
          ^~~~
roverboy774-STACKS.cpp:19:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’
           if(start>end)
           ^~
roverboy774-STACKS.cpp: In function ‘int main()’:
roverboy774-STACKS.cpp:53:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i=0;i<vec.size();i++)
                   ~^~~~~~~~~~~
+ set +x
Successful
[simon@simon-laptop][12:26:02]
[~/devel/hackerrank/otherpeoples]>echo "3                                                       
6
3 4 5 1 1 2
10
3 2 9 5 2 9 4 14 7 10
8
14 5 13 19 17 10 18 12
" | ./a.out
/usr/include/c++/7/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 1, but 
container only holds 1 elements.

Objects involved in the operation:
    sequence "this" @ 0x0x7ffe4f4b8b20 {
      type = std::__debug::vector<long long, std::allocator<long long> >;
    }
Aborted (core dumped)

1 Like