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

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

6B - President's Office I submitted this solution — 69647174

What I am trying to do is to start dfs starting on the first cell of the president's table. If there is another table in that cell's neighbour i call the color function which is also dfs but on the deputy's table and increase the ans (res) by 1.

I do not know what is wrong in this approach. Can anyone help?

UPD: Solved thanks to CodingKnight

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

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

No need for dfs here.

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

The following accepted solution is a C++17 version of your Java code with slight updates.

69660777

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

    Thanks a lot man! I found the bug in my code comparing with yours. Thanks a bunch

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

      With pleasure. The following is yet another update to the DFS C++17 code in which a third paremeter is added to the DFS function that defines the branching DFS function called when the next location is valid. The color function is not performed as separate version of the DFS function, but using another call of the same DFS function with different branching function parameter.

      69703758

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

There's no need of dfs but then also I implemented it using graphs in C++ and got it accepted. U can find my submission here. 69730654

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

    You can even simulate the set of distinct characters using a 0/1 array of integers, as the number of deputies is guaranteed to not exceed 25.

    69800381