We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The value returned by v.max_size() is 2^62-1 which would seem to indicate that the server architecture is 64-bit. Anyway, the timeout occurs with A much less than 2^30 (as low as 0x7ffffff in my minimal tests). The message "Terminated due to timeout" means what it says, that the process has exceeded a time limit and will be terminated (most likely via SIGKILL) and there will be no way to catch or handle the termination. You can try to narrow down which value of A is the minimum with which the timeout occurs, but most likely this value is indeterminant.
The Server::compute() function calls the "fill" vector constructor to create a vector of A elements initialized to 0. But Server::compute() only accesses one element, the one at index B. If instead the "range" vector constructor were used, a vector of one element would suffice, and I believe that the timeout could be avoided entirely. Alas we are not permitted to change anything inside the Server class.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Exceptional Server
You are viewing a single comment's thread. Return to all comments →
Thank you, CO, but the question remains, why ?
The value returned by v.max_size() is 2^62-1 which would seem to indicate that the server architecture is 64-bit. Anyway, the timeout occurs with A much less than 2^30 (as low as 0x7ffffff in my minimal tests). The message "Terminated due to timeout" means what it says, that the process has exceeded a time limit and will be terminated (most likely via SIGKILL) and there will be no way to catch or handle the termination. You can try to narrow down which value of A is the minimum with which the timeout occurs, but most likely this value is indeterminant.
The Server::compute() function calls the "fill" vector constructor to create a vector of A elements initialized to 0. But Server::compute() only accesses one element, the one at index B. If instead the "range" vector constructor were used, a vector of one element would suffice, and I believe that the timeout could be avoided entirely. Alas we are not permitted to change anything inside the Server class.