Why do I get SIGSEGV? [COOK82C]

Can anyone tell me why I am getting SIGSEGV for this solution CodeChef: Practical coding for everyone to the problem COOK82C Problem - CodeChef and what does it mean?

Consider the testcase:

4 4
168 183 112 169 
1
2
3
4
[~/devel/hackerrank/otherpeoples]>cat failed_test_case.txt | ./a.out 
183
169
168
112
/usr/include/c++/7/debug/vector:447:
Error: attempt to access an element in an empty container.

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

Thanks, now I don’t get SIGSEGV. But I do get TLE.
But now at least I know that it is not my implementation which is incorrect but my algorithm.

1 Like

As it seems like you have access to all the test cases, can you tell me why my new code gives SIGSEGV as well? CodeChef: Practical coding for everyone

I don’t have access to all the testcases - just 10’000 randomly-generated ones :slight_smile:

They didn’t turn up any issues with that submission, I’m afraid :confused:

Edit:

I recommend never, ever mixing floating point with integers - it’s always a recipe for disaster. In particular, avoid using pow.

2 Likes

Thanks for the advice! It finally worked! :smiley: (had to use totally different approach of implementing.)

1 Like