%--------------------------------------------------------------------------------
-\section{Hatcheck lady and other derangements}
+\section{Restricted permutations}
Another interesting class of combinatorial objects which can be counted and
ranked are restricted permutations. An~archetypal member of this class are
and $\O(n^2\cdot t(n))$ by the computations of the~$N_0$'s.
\qed
-\rem
-This time bound is obviously very coarse, its main purpose was to demonstrate that
+%--------------------------------------------------------------------------------
+
+\section{Hatcheck lady and other derangements}
+
+The time bound for ranking of general restricted permutations shown in the previous
+section is obviously very coarse. Its main purpose was to demonstrate that
many special cases of the ranking problem can be indeed computed in polynomial time.
For most families of restriction matrices, we can do much better. One of the possible improvements
is to replace the matrix~$M$ by the corresponding restriction graph and instead of
These speedups are hard to state formally in general (they depend on the
structure of the matrices), so we will concentrate on a~specific example
-instead. We will show that for derangements one can achieve linear time complexity.
+instead. We will show that for the derangements one can achieve linear time complexity.
-\examplen{Ranking of hatcheck permutations a.k.a.~derangements}\id{hatrank}%
+\nota\id{hatrank}%
As we already know, the hatcheck permutations correspond to restriction
matrices which contain zeroes only on the main diagonal and graphs which are
complete bipartite with the matching $\{(i,i) : i\in[n]\}$ deleted. For