Please read the new rule regarding the restriction on the use of AI tools. ×

RobinFromTheHood's blog

By RobinFromTheHood, history, 4 days ago, In English

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
»
3 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    3 hours ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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]

    • »
      »
      »
      3 hours ago, # ^ |
        Vote: I like it +2 Vote: I do not like it

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

      • »
        »
        »
        »
        3 hours ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Exactly!

  • »
    »
    3 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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
  • »
    »
    115 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
3 hours ago, # |
  Vote: I like it +1 Vote: I do not like it

Lightning fast editorial

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Wow , problem G is so simple. Solid Problemset!

»
3 hours ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

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

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
3 hours ago, # |
  Vote: I like it +1 Vote: I do not like it

H should be placed before F imo

  • »
    »
    3 hours ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

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

  • »
    »
    2 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
3 hours ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 .

  • »
    »
    2 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      118 minutes ago, # ^ |
      Rev. 5   Vote: I like it 0 Vote: I do not like it

      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

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
3 hours ago, # |
  Vote: I like it +12 Vote: I do not like it

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

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    3 hours ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    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

  • »
    »
    3 hours ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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]

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

still i didn't understand E :)

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    2 hours ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    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.

»
106 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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)$$$.

  • »
    »
    79 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
101 minute(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
55 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    42 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      37 minutes ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

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

      • »
        »
        »
        »
        13 minutes ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.)

»
19 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

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.net/blog/entry/134087?#comment-1200754

»
15 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

how is editorial even published 4 days ago?!