It's the first problem for me to solve with DFS , So I can't understand why it's wrong Answer on test 6 The link of code and submission : http://codeforces.net/contest/580/submission/30840380 Problem link : http://codeforces.net/problemset/problem/580/C