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

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

In the latest contest I solved 2028C - Alice's Adventures in Cutting Cake in ~ O(nlog(n)). My first submission got TLE, which I found odd so I optimized it — tighter bound for BS and static array used for DP, which passed in 200ms.

Then I started adjusting my original solution and found out that if I use C++23 (GCC 14-64, msys2) instead of C++20 (GCC 13-64), the solution passes. If I create a single static vector, the solution is much faster.

C++23 (GCC 14-64, msys2): 291080726 — ~ 1400ms

C++20 (GCC 13-64): 291080768 — TLE

Single static vector: 291080651 — ~ 300ms

I have two questions:

1) Does anyone know why the compiler version changes the runtime so dramatically and how to prevent it?

2) Since creation of a vector is linear in its size, why is the runtime increased so much?

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

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

Автор Filikec, история, 3 месяца назад, По-английски

Hi there, I've been looking at submissions for the latest DIV3 and I've noticed something that has surprised me quite a lot.

People placing intentional bugs in their code?

I filtered submissions by status "hacked" and I've noticed that a lot of those submissions have some code inserted in them that is very obviously meant to be hacked.

For example for problem 2000E - Photoshoot for Gorillas, there's many submissions with code such as this:

if ((n ^ m) + (k ^ w) == MAX_N) {
    cout << "0\n";
    return;
}

Why do people* submit such solutions?

*subject to speculation

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

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

Автор Filikec, история, 5 месяцев назад, По-английски

Hello there,

This is my first blog, which is about making mistakes and learning from them. Hopefully it will be of use to someone.

Be careful with accumulate!

Last competition was one of my worst performances ever Codeforces Round 956 (Div. 2) and ByteRace 2024. It wasn't obvious to me how to solve B so I skipped it and started working on C which I thought is pretty straightforward. I ended up submitting 9 wrong submissions on C and wasting almost all my time on it.

It turns out that all my submissions were correct aside from one little nasty bug. I used the function "accumulate" to sum values in a vector of long longs but it turns out that accumulate sums them as ints instead of long longs...

Here is my first submission for C 269261777 and here's a submission I made after the contest that got AC 269299787. You may notice that the only difference is in the accumulate function.

What to do after such a mistake?

There's really only one thing that can be done after such a mistake. Suck it up and learn from it.

Rating

I used to care a lot about my rating, which is why I started conditioning myself to not care about it as much. Of course, I still do care about my rating and caring about one's rating can be a good motivator for improvement. However I believe that caring a little too much can certainly be detrimental. In this case, it is much easier for me to learn from this mistake than it would've been had I not started trying to not care as much. Also, caring too much about my rating could prevent me from making mistakes from which I could learn.

Stop caring about rating. Care about being good.

The way I started caring less about rating is that I participated pretty much in every contest despite the circumstances. Visiting a friends house for a few days? I can do a contest. Not feeling prepared at all? Doesn't really matter, still can learn from the contest. Being ill (happened this time)? Same thing. Having a completely foreign setup (pc,mouse,keyboard,editor)? Improve, adapt, overcome.

I do wonder whether I'm not taking it too far as there are cases where I'm pretty sure that I'm going to lose rating and I participate regardless. Maybe not participating and just doing a virtual contest later would have a similar effect while preserving rating. However, I feel that from the competitions where the conditions are most unfriendly, I learn the most.

tl;dr: Cope

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

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