Why STL implementation is not getting accepted

Question Link : https://www.codechef.com/problems/WALKFAST
I was trying to solve the above mentioned question. But because of logical error it was not accepted. After few trial I looked into the submissions of other people. Which was accepted.
Copied Solution link : https://www.codechef.com/viewsolution/28415135
Link of submission made by me
link1 : https://www.codechef.com/viewsolution/28415817 (my code with same logic only difference is using vector instead of array not accepted)
link2 : https://www.codechef.com/viewsolution/28415843 (@sachin_4099 code with vector not accepted)

Link of submission which is accepted without use of vector
link : https://www.codechef.com/viewsolution/28415865

Please explain why I am getting wrong answer or run time error when I am using vector in place general array. I tried many times but every time the solution was rejected. Explain the fault in my code whose link is mentioned above. Link of whole submission of FASTWALK is : https://www.codechef.com/status/WALKFAST,hariomdeo

That’s not the only difference: in your vector version, you have:


which is different to your array version:



While I’m at it - there’s really no good reason to use std::vector::at instead of std::vector::operator[] in CP (it’s just slower for no benefit), and there’s no need to clear() a vector that is about to go out of scope :slight_smile:


Thanks for your(@ssjgz ) support. That was my mistake. Explain one more thing. What is the meaning of
int arr[320]{0};
Thank you again

1 Like

It’s an array of 320 ints, all of which are initially 0.

1 Like