ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1034. Ферзи в мирной позиции

Hint
Послано frochbg 3 окт 2020 13:37
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
Послано frochbg 8 окт 2020 13:15
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!