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

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

Problem Name: Monsters.

There are N Monsters numbered from 1 to N , each of type Fire, Water or Grass represented by a string A of length N . When two Monsters battle each other, one of them wins according to the following rules: • A Fire Monster always defeats a Grass Monster. • A Water Monster always defeats a Fire Monster. • A Grass Monster always defeats a Water Monster. • In a battle between two Monsters of the same type, either one can win. Answer Q queries of the following form: if the Monsters Lj ...Rj are standing in a line from left to right, and repeatedly, two adjacent Monsters battle each other with the loser leaving the line, how many Monsters can be the last remaining Monster in at least one valid sequence of events?

Problem Link: Monsters

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

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

900 maybe 1100

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

If there are 3 monsters, does the 2nd monster battle 1st monster or 3rd monster?

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

    If there are three monsters, First the first and the second monsters fight, whoever loses gets kicked out and there will be two monsters left.. whoever is left fights the third monster,

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

If you can arbitrarily choose which pair of adjacent Monsters to battle, I think a Fire Monster $$$i$$$ can win if and only if:
- In the left side of $$$i$$$, there is at least one Grass Monster, or there is no Water Monster.
- In the right side of $$$i$$$, there is at least one Grass Monster, or there is no Water Monster.
We can use data structures to answer queries.

Please correct me if I'm wrong.

If this is intended, I'd rate it 1800+. But according to previous comments, this approach maybe severely over-complicated.

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

    If you didn't understood the problem, please read the full problem statement.

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

    Yes, this is intended (as an INOI 2024 silver medalist). No, it is not overcomplicated; the official editorial uses the same solution.

    The previous comments are probably referring to solving the $$$Q=1$$$ subtask, which is actually quite easy and doesn't need any data structures (and surprisingly it yields you $$$84$$$ points)

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

    Your overall approach is correct but you don't need data structures. You can simply use prefix sums to count the number of Fire Monsters between the first Water Monster and first Grass Monster, and so on. (I am the author of the problem.)

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

Auto comment: topic has been updated by AvadaKedavara (previous revision, new revision, compare).