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

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

Hi everyone , i am trying to solve SCPC14 in gym and particulary i was thinking how to solve problem G i think a naive bruteforce with backtracking but it was very slow .

Can somebody give me some hints in order to solve this problem.

Thanks in advance.

Link

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

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

I think BFS will work, because there are not too many different board states.

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

    Believe me that using bfs inside your backtracking and searching all board states it's so slow , must have some prunning or similar in this problem.

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

      have you tried BFS and failed? the fact that number of different colors is only 4 and the cells are shifted to left and down makes number of states very low , also you can use previously computed states in many test cases in the same test file

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

        In fact the sample input runs so slow . I think that the number of states it's huge.

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

          Maybe there's something wrong in your code , here's one of AC solutions code

          as you can see it did nothing more than DFS with memorization to states

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

          We have 5 x 6 board. Each column can be some subset of itself, but some subsets are unreachable. It gives higher bound to 2^30 states. Note it's a higher bound and in practice is not reachable.

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

            I also suspect this with my backtracking aprouch without prunning

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

      Simple prunning that helps a lot — you definitely can't solve a board where you have only one object of some type left.