ldyllic's blog

By ldyllic, history, 4 weeks ago, In English

For a great while of my CP career I had no idea how such, at a first glance, insignificant things might affect the runtime of the code. And till this day I keep seeing many beginners having lack of knowledge about this so-called effect, that's why I would like to share it here and hope it'll help you out someday.

1 code 164992399 executes in a time of 1918ms.
2 code 164991769 executes in a time of 280ms.

Notice 2 drastically different runtimes (6x difference!). The reason for that is pretty straightforward: in this code one of three IF statements (IF statement with == 2) gets a true response way more often than others. While the first code has an IF statement with 2 at the end, the second code has such IF statement at the beginning.

Knowing this we can make a conclusion: the order of IF statements matters, and sometimes matters a lot (you get AC or TLE). So whenever you hit (or feel you might hit) the bound of the time limit you always want to check whether all IF statements are placed in the right order and if not — a little change might make you happier by seeing this lovely green Accepted word.

upd. As Apachee mentioned in the comments if you wish to avoid thinking where it is better to put one or another IF statement you can use switch-case method which helps to achieve the same runtime as the second code 165019894.

Read more »

 
 
 
 
  • Vote: I like it
  • +34
  • Vote: I do not like it

By ldyllic, history, 2 months ago, In English

Hello, CodeForces!

I have just solved 1 problem and I made quite a lot new observations for me. Could anybody explain me, please, the reason behind the behaviors that I will explain here? Thanks a lot!

That is the problem — nothing outstanding, simple implementation 1575J - Jeopardy of Dropped Balls. However to be able to help me out, you will need to get into this problem to see what I will state below :)

A bit of story: while doing CP I was often wondering about the engines behind the code, how and what executes, what takes care of what etc. Hence, I decided to make some experiments on this problem.

First code: 160046810 — [1980ms]. In a while loop I access an element with parameter 2 at the else statement. This parameter just increases x and moves forward, while 2 first statements increase / decrease y + change an element in a matrix. Container for a data is 0-indexed.

Second code: 160047806 — [483ms]. Here in a while loop I access an element with parameter 2 at the first if statement and other statements where I need to change matrix elements follow after. Array is still 0-indexed.

Third code: 160047849 — [280ms]. Everything is similar to the second code, but array is 1-indexed.

I am mostly interested in a reason of difference between 1st and 2nd code, but if you could point out the same between 2nd and 3rd — that will be amazing!

Read more »

 
 
 
 
  • Vote: I like it
  • +8
  • Vote: I do not like it

By ldyllic, history, 2 months ago, In English

Hey, CodeForces!

I am seeking for your advice: how to improve my skills of figuring out test cases where my program fails? I have been facing quite a few WA on 100+, 300+ test cases and each of the times I wasn't able to get what was that edge case by myself. Hence, I am asking you guys for an advice :)


And in particular — what is the edge case here?

This is my submission: https://codeforces.com/contest/264/submission/159610034

This is the problem: https://codeforces.com/contest/264/problem/B


Thank you all for your help!

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By ldyllic, history, 2 months ago, In English

Hello, CodeForces and especially admins!

Being into CP from February I have seen many blog posts. And many of them are either educative or interesting for me, therefore I want to keep them somewhere nearby. Unfortunately, as of now, here at CodeForces, we don't have such opportunity and in my opinion it is really important gap to fill. To keep track of some blog posts I have to add to my friend list particular blog writers. However after some time it is hard to remember who is who and what he had posted.

My suggestion — it can be anything starting from "Favorite" section ending with a storage in our profile where we could save and keep important posts for each of us. It will be a huge improvement for CodeForces in my opinion and obviously it'll help a great number of CP competitors.

Spread this word, suggest your ideas down in the comments! I have high hopes that this message will be heard out, have a great one!

For those who didn't know it already exists — check the first comment, I guess it is not that well known or I simply wasnt aware of it for some reason. You can click on a star near the upvote and downvote buttons and on the right side in your "profile" square (above the rating) will appear "Favorites" section where these blogs will be stored.

Read more »

 
 
 
 
  • Vote: I like it
  • +23
  • Vote: I do not like it

By ldyllic, history, 3 months ago, In English

Are there any news about when and probably where Hacker Cup will take place this year? I have scanned many sources, but barely got any new useful information about the event.

upd. The qualification round is scheduled on 26 of August 2022. Thank forchapearl1 in the comments for providing information!
The link for registration:
https://www.facebook.com/codingcompetitions/hacker-cup/

Read more »

 
 
 
 
  • Vote: I like it
  • +66
  • Vote: I do not like it

By ldyllic, history, 3 months ago, In English

Hey guys!

Currently chilling out after an intensive day and solving some CF problems. And suddenly after solving a great problem I asked myself: what is the greatest contest out there in a whole CF 12-ish year journey?

I know it is pretty subjective, however I'd still like to hear what is your guys favorite contest on a CF so far? More than that probably you could point out what kind of problems do you enjoy the most?

Or if it is hard to remember/find your best you could probably convey a general idea of what that contest was? And if you think you haven not found your ideal yet — make sure to share what you feel will be the best fit for you!

If this blog will get a great feedback I might do something like a statistics (definitely entertaining one, not just useless numbers).

Read more »

 
 
 
 
  • Vote: I like it
  • +15
  • Vote: I do not like it

By ldyllic, history, 4 months ago, In English

I have to admit that this contest week (04.17 — 04.24) was incredible, almost everyday events starting from div4 rounds (what was pretty interesting to try) and ending on global round 20. A full range of problems including interactive problem in the very last contest. For me as for the guy who's doing CP only for 3 months it was a great experience and I'm so grateful to all problem setters, testers, competitors and everybody who was involved in this week's events for making it that entertaining! I definitely gained a lot of new skills and I'm full of hope that we all will have the same weeks more frequent and I aim to get one in a near future :)

Read more »

 
 
 
 
  • Vote: I like it
  • +71
  • Vote: I do not like it

By ldyllic, history, 4 months ago, In English

Hello everyone!

So if there're any admins or developers for CodeForces or enthusiasts out here — I've got an idea:

What if you guys would implement a system of quick contests 1v1, 2v2... The key idea is that everybody will be able to create a quick contest in a particular area to have a brief competition with his friend(s) to enhance their skill or just have some fun. Problems will be randomly chosen from an archive (as of now) and one will be able to set their amount.

I think this idea has a lot of potential since it hasn't been made anywhere yet. This can be a way to widen our relatively small CP community and throughout the time other mechanisms can be created based on this existing one.

Read more »

 
 
 
 
  • Vote: I like it
  • +92
  • Vote: I do not like it