### miniluigi's blog

By miniluigi, history, 8 years ago,

Hello,

I have spent a good amount of time trying to debug 587C. However, I am getting WA Test 30.

There seems to be something wrong with merging (not necessarily the method itself), as in my answer I end up outputting a duplicate of each number in the second line of the Output on test 30

10 1 1 4 4 5 5 6 6 8 8

However, I believe I designed my code so that the code should not be merging overlapping vectors. If someone could be so kind as to help me pinpoint the error, I would be very thankful.

EDIT: User Benq helped me find the error; it was just because my LOG value was not big enough :(

• +34

By miniluigi, history, 8 years ago,

Hello, I recently solved Snail Trails (problem statement here, and I have no idea why my code did not TLE. In fact, it finished in 0.011 seconds on all test cases. To summarize my approach, it's a brute-force DFS on every possible option. Can anyone help me analyze the time complexity of my code? Any help and insight would be appreciated. Thanks!

• -5

By miniluigi, history, 8 years ago,

When I was coding a solution for 633E, I noticed that using

int log(int x) {
int ct = 0;
int k = 1;
while (k <= x) {
k *= 2; ct++;
}
return ct-1;
}


over floor(log2(x)) allowed my program to run in time. Could someone please explain to me why one is faster than the other? Thanks!

See here for my code and use compare to see that nothing else is different:

floor(log2(x)): http://codeforces.com/contest/633/submission/18990181

• +8

By miniluigi, history, 8 years ago,

I have tried to use the Sparse Table Algorithm in order to compute the RMQ in this problem. However, this ends up timing out. I thought it was O(nlogn)?

http://codeforces.com/contest/689/submission/18959912

• +3