Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Ought to be fixed now
Yes your solution is correct, there seems to be an issue with the code. I'll fix it sometime soon
One operation is combining any two adjacent numbers by adding them, so only addition is allowed. The answer for that particular one is adding all the 1s to get
[3,3,3,4,4,4,4,4]
Removed using namespace std and passing n to the function.
As for the
vector<ull>
, it became a habit of mine to always take in inputs as ull or ll after overflows on CF and the like. But I changed it tovector<int>
as you suggested.I hadn't thought of that. Mb, switched to
vector<pair>
instead@poltrona14 my solution is O(1) with no brute forcing involved uwu
Eh sometimes you gotta use it, not here ig. This can be done in O(1) without any loops
This comment is hidden because it contains spoiler information about the solution
fixed
This comment is hidden because it contains spoiler information about the solution
You might wanna try again, It wont work for n <= 1 and n == 4
yea, I changed the while to a for loop and the 6k one is faster almost always but the time difference is still in the same range and fluctuates wildly. I never realized that while loops are slower than for loops in python, ty for letting me know
also I have no idea why my reply got posted twice
hmm, the results of comparing the two often turns out to be wildly inconsistent in time difference but remains in the 1-10µs range, tho I found that the n = 19 and 1009 takes longer with 2k, n = 10000000019 takes less with the 2k one most of the time. Code used for testing:
Loading more items...