CodeChef: Practical coding for everyone : link for my code.
If I try custom input with given test cases, I am getting right answers. But when I submit the problem, It gives me the Runtime error(SIGSEGV).
Thanks!
CodeChef: Practical coding for everyone : link for my code.
If I try custom input with given test cases, I am getting right answers. But when I submit the problem, It gives me the Runtime error(SIGSEGV).
Thanks!
Compiling with clang reveals the issue immediately:
[simon@simon-laptop][16:36:39]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh clang
clang
Compiling atharva_u1-COPS.cpp
+ clang++ -std=c++14 -stdlib=libc++ atharva_u1-COPS.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_LIBCPP_DEBUG=1 -L/home/simon/devel/clang-git/install/lib/ -fsanitize=undefined,bounds,integer -ftrapv
atharva_u1-COPS.cpp:12:17: warning: variable 'm' is uninitialized when used here [-Wuninitialized]
int arr[m];
^
atharva_u1-COPS.cpp:11:11: note: initialize the variable 'm' to silence this warning
int m , x , y , valuep = 0 , valuen = 0, count = 0;
^
= 0
1 warning generated.
+ set +x
Successful
No idea why gcc doesn’t.
Edit: Maybe because variable-sized arrays aren’t standard C++? Dunno.