I solved this problem using backtracking with optimization( you start from some position and then you go to the position that has the fewest future possible moves...//from other post). But it's WA 3. Then I checked the answers of my program myself and all was correct.Then I wrote a simple checker for this problem. And it said all right. Then I tried to save the answers(firstly my answers then answers from forum) as the constants in the program. And the answer was WA 3 again. Help me, please!!!