Блог пользователя miniluigi

Автор miniluigi, история, 8 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор miniluigi, история, 8 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор miniluigi, история, 8 лет назад, По-английски

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:

log(x): http://mirror.codeforces.com/contest/633/submission/18990265

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор miniluigi, история, 8 лет назад, По-английски

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://mirror.codeforces.com/contest/689/submission/18959912

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится