Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

Thank you all for participating in the round! We hope you had fun, as we did thinking of the problems. We would like to again thank our coordinator Vladosiya who made many suggestions for improving all problems here, and rejecting others.

2014A - Robin Helps

Author: RobinFromTheHood

solution
code python
code cpp

2014B - Robin Hood and the Major Oak

Author: ChairmanFMao; Developer: Filikec, RobinFromTheHood

solution
code python
code cpp

2014C - Robin Hood in Town

Author: RobinFromTheHood; Developer: Filikec, RobinFromTheHood

solution
code python
code cpp

2014D - Robert Hood and Mrs Hood

Author: RobinFromTheHood; Developer: ChairmanFMao; RobinFromTheHood

solution
code python
code cpp

2014E - Rendez-vous de Marian et Robin

Author: RobinFromTheHood; Developer: Filikec, RobinFromTheHood

solution
code python
code cpp

2014F - Sheriff's Defense

Author: Filikec; Developer: Filikec

solution
code python
code cpp

2014G - Milky Days

Author: RobinFromTheHood; Developer: Filikec, RobinFromTheHood

solution
code python
code cpp

2014H - Robin Hood Archery

Author: Filikec; Developer: Filikec

solution
code python
code cpp
  • Проголосовать: нравится
  • +36
  • Проголосовать: не нравится

»
6 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

gigafast editorial 😬 btw for problem H, isn't checking (r — l) odd and number of uniq element is sufficient to answer query? I received WA2 with that approach

  • »
    »
    6 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    the number of unique elements can be greater than 1 and yet the array is not losing.

    Here is an example:

    [3, 3, 1, 1]

    • »
      »
      »
      6 часов назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      oh now I see, so frequency of element between l to r should be even

      • »
        »
        »
        »
        6 часов назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Exactly!

  • »
    »
    6 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    If by number of uniq element you mean printing YES iff the number of unique elements is 1, this misses other cases where its possible.

    Consider the following test case:

    Counter-case
  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    the only check you need is whether any element appears an odd amount of times. if yes then the answer is no, and otherwise the answer is yes

»
6 часов назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Lightning fast editorial

»
6 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Wow , problem G is so simple. Solid Problemset!

»
6 часов назад, # |
Rev. 2   Проголосовать: нравится +12 Проголосовать: не нравится

Problems are good, except for H which is a bit too common (but still educational :)). Fast editorial!

»
6 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

gonna hate myself for the rest of my life for messing up C.... i was sooooo closeeee

»
6 часов назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

H should be placed before F imo

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    We were discussing placing H differently but ended up placing it here as it needs specific algorithms. G could be solved with nothing advanced.

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I guess despite the fact that H turned out to be a famous problem, F didn't require any advanced algorithms knowledge. So it has a better chance to be solved by lower rated people

»
5 часов назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

For problem C I used binary search on the possible values of x. When I made the upper bound of x = n*max_element+1 it gave WA but when I gave it as 1e18 it was accepted. Can someone explain this?

EDIT: originally wrote 2*max_element+1 . Updated to n*max_element+1 which is the upper bound that gave WA instead of 2*n*max_element

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I also encountered a similar issue when I solved the "C — Maximum Median" problem. I'd like to understand the story or concept behind this problem .

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    maximum value of x can be (n * max_element + 1), in the case where all values are equal to max element

    • »
      »
      »
      5 часов назад, # ^ |
      Rev. 5   Проголосовать: нравится 0 Проголосовать: не нравится

      Sorry, made a typo. I set the upper bound to n*max_element+1 in my solution but got WA before changing it to 1e18. What is wrong here? Is the division causing problem? Why is 2*n*max_elementthe correct upper bound?

      here is accepted 282332784

      and WA version 282330368

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

F is really nice. Consider a parent and child combination. If parent is not strengthened, then the answer remains unchanged. If the parent is strengthened then there are two cases:

  1. If child is not strengthened, then they lose c gold but it doesn't matter as it is not going to be counted anyway.

  2. If child is also strengthened, then it costs c from the parent, but now the deficit of c from the child also counts, so in total we get a[i] - 2*c in this case.

»
5 часов назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

Glad we have proper anti-wrong-Dijkstra tests on E :)

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why do we need random numbers for the xor solution in H? Wouldn't the xor always be 0 if every element in a range occurred an even # of times?

  • »
    »
    5 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    If you xor the original numbers instead of random ones, some of them may emit a zero even if not every element occurs $$$2k$$$ times. E.g. 1 2 3

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    yes but the XOR can also be zero even though the range has some elements occuring odd number of times.

    for example:

    [1, 2, 3]

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

still i didn't understand E :)

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

A job between days li and ri would overlap with the visit if the start day x satisfies li−d+1 ≤ x ≤ ri

I didn't get this statement. Can somebody explain this?

  • »
    »
    5 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    We can rearrange $$$l_i - d + 1 \le x$$$ to get $$$l_i \le x + d - 1$$$. If a visit starts on Day $$$x$$$ and spans $$$d$$$ days, Day $$$x + d - 1$$$ is exactly the last day of the visit. So $$$l_i \le x + d - 1$$$ means the job starts earlier than or exactly when the visit ends.

    Likewise, $$$x \le r_i$$$ means that the job ends later than or exactly when the visit starts.

    More intuitively, they overlap when there is at least one day where you would have to do some job while visited by your mother/brother.

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I don't understand dijkstra probably. How does it get the correct shortest paths from source 1 for the sample test 5.

3 2 1
2
1 2 4
1 3 16

How does it go to $$$2$$$ and take the horse and come back ? Since d[source=1] = 0, I assume it(the source) would not (and should never ?)get relaxed by $$$2$$$. Also, there isn't any edge $$$E(2,3)$$$.

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    You have to calculate two times for each vertex. The fastest time to get there without using a horse and the fastest time to get there using a horse. If you get on a horse at vertex v, then you continue traversing the graph, but you have to start updating the times for when you're on a horse.

    So in your example, you get on a horse at vertex 2 then go to vertex 1 since d_with_horse[1] = INF

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can someone provide a solution in python for problem B without using import sys, I am getting Time Limit Exceeded error

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I used same logic in C but still got WA. Can anyone tell my why? Thank you in advance. I did 2 different code but same logic. Still can't understand why it wasn't accepted.

282360605 282336672

  • »
    »
    3 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Both a[lastman] and n are ints, so a[lastman]*2*n can overflow when these are large.

    • »
      »
      »
      3 часа назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Sorry if this is a dumb question, but ansis long long. So it shouldn't be a problem?

      • »
        »
        »
        »
        3 часа назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        It doesn't matter whether you're assigning the result to a long long. You should note that every operation is done with types, and a[lastman]*2*n is a series of operations that is done only with int types. The overflow occurs right here, and assining is done after this overflow already happened. Once the overflow happens, there is no way to fix it back — its value is already broken (to be precise, it is already an undefined behavior.)

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

E can also be solved with a different approach Also. My idea is related to binary search the answer

Comment link of Solution : https://codeforces.me/blog/entry/134087?#comment-1200754

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

how is editorial even published 4 days ago?!

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why my solution is getting WA in problem H

Submission: https://codeforces.me/contest/2014/submission/282384796

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I'm not sure if this was luck or actually correct

can someone try hacking this code for B

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For using hash for problem H, one need to use at least 64-bit hash or dual-hash.

Recall the probability for hash collision is $$$1-exp\left(-\frac{n(n-1)}{2d}\right)$$$, where $$$n$$$ is the number of elements and $$$d$$$ is the hash space.

if $$$n=1e6, d=2^{32}$$$, $$$1-exp\left(-\frac{n(n-1)}{2d}\right)\approx 1$$$ and it can be hacked

if $$$n=1e6, d=2^{64}$$$, $$$1-exp\left(-\frac{n(n-1)}{2d}\right)\approx 2.71e-08$$$