Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

LightYagami674's blog

By LightYagami674, history, 5 weeks ago, In English,

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

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

»
5 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

No need for dfs here.

Spoiler
  • »
    »
    5 weeks 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 weeks 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 weeks 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

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

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

»
4 weeks 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