|
|
вернуться в форумHint I have been trying to solve this problem for several days, but suddenly I ran out of ideas. Could you give me some hints on the task? I have tried brute force and some pruning, but it got TLE. I would be really happy! :) Re: Hint I've got AC! The main observation is that no two queens can be in the same row or column. Thus, we make an array perm[i], which stands for queen in the ith row and perm[i]th column. The problem is to find the number of permutations, which differs from the initial by 3 elements and check for each possibility whether we have conflicts on the diagonals. perm[i] is the initial permutation. I hope this hint was helpful! |
|
|