LightYagami674's blog

By LightYagami674, history, 5 years ago, In English

6B - Кабинет президента 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

  • Vote: I like it
  • -5
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

No need for dfs here.

Spoiler
  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Ya man i checked the editorial too, I know but I m curious about what is wrong with dfs solution

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

69660777

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

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

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

      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

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

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

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

    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