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

Автор towersfreak2006, 4 недели назад, По-английски

I'm looking for a data structure or subroutine that takes in a sorted list $$$L$$$ of $$$n$$$ integers and a list $$$Q$$$ of $$$n$$$ integers. For each element $$$q\in Q$$$, we should report the largest remaining element in $$$L$$$ smaller than $$$q$$$ and then remove it (or we can report $$$-1$$$ if no such integer exists). I would like the entire process to take $$$O(n \log n)$$$ time.

My understanding is that this approach is necessary for today's 2254E - Chronostasis, but many user-accepted Python solutions seem to implement Fenwick trees, which I believe might be too complicated for a Div. 3 contest and not the intended solution (though I could be wrong).

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

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

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

Hi there,

Someone much more knowledgeable than me warned about using sets and dictionaries in Python as they can be hacked. I somewhat overlooked this advice as I assumed no one would hack a random pleb, but then I saw a warning in the editorial of 1915E - Romantic Glasses at https://codeforces.me/blog/entry/123952 state "Be careful about using hash tables, as they can be hacked."

One of the responses in that thread linked to https://codeforces.me/blog/entry/62393 which provided some insights and workarounds for C++, but is there such a resource for Python? Is there a general rule of thumb for using such data structures and finding the appropriate problem-specific alternative (such as a list of tuples, which will often do)?

Thanks in advance!

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

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