An illusionist and their assistant are about to perform the following magic trick 
Let $k$ be a positive integer. A spectator is given $n=k!+k−1$ balls numbered $1,2,\dotsc,n$. Unseen by the illusionist, the spectator arranges the balls into a sequence as they see fit. The assistant studies the sequence, chooses some block of $k$ consecutive balls, and covers them under their scarf. Then the illusionist looks at the newly obscured sequence and guesses the precise order of the $k$ balls they do not see.
Devise a strategy for the illusionist and the assistant to follow so that the trick always works.


(The strategy needs to be constructed explicitly. For instance, it should be possible to implement the strategy, as described by the solver, in the form of a computer program that takes $k$ and the obscured sequence as input and then runs in time polynomial in $n$. A mere proof that an appropriate strategy exists does not qualify as a complete solution.)


Source: Komal, October 2019, problem A $760$.
Proposed by Nikolai Beluhov, Bulgaria, and Palmer Mebane, USA


I can prove that such a strategy must exist:
We have a set $A$ of all permutations (what assistant sees) and a set $B$ of all possible positions of a scarf (mark it $0$) and remaining numbers (what the illusionist sees).
We connect each $a$ in $A$ with $b$ in $B$ if a sequence $b$ without $0$ matches with some consecutive subsequence in $a$.  Then each $a$ has degree $n-k+1$ and each $b$ has degree $k!$. Now take an arbitrary subset $X$ in $A$ and let $E$ be a set of all edges from $X$, and $E'$ set of all edges from $N(X)$ (the set of all neighbours of vertices in $X$). Then we have $E\subseteq E'$ and so $|E|\leq |E'|$. Now $|E|= (n-k+1)|X|$ and $|E'| = k!|N(X)|$, so we have $$ (n-k+1)|X| \leq k!|N(X)|\implies |X|\leq |N(X)|.$$
By Hall marriage theorem there exists a perfect matching between $A$ and $B$...
...but I can not find one explicitly. Any idea?

Update: 2020. 12. 20.

*

*https://artofproblemsolving.com/community/c6t309f6h2338577_the_magic_trick

*https://dgrozev.wordpress.com/2020/11/14/magic-recovery-a-komal-problem-about-magic/

NOTE: I found counterexamples to the explicit $f$ I initially posted. I removed it but am leaving the rest of the answer up as a partial solution.

Notation and Remarks
Let $S_n$ denote the set of permutations of length $n$ and let $C_{n,k}$ be the set of covered permutations. For example, the permutation $12345678 \in S_8$ and $123\cdot\cdot\cdot78 \in C_{8,3}$. For brevity I often drop the subscripts.
The act of covering gives us a relation $\sim$ between the two sets, i.e. we say that $\pi \in S$ and $c \in C$ are compatible if $c$ is a covering of $\pi$. We can visualize this compatibility relation as a bipartite graph. For $k=2$ and $n=3$ we have:
$ \qquad \qquad \qquad \qquad \qquad \qquad $

We need to find an injective function $f : S_n \rightarrow C_{n,k}$ such that $\pi$ and $f(\pi)$ are always compatible. The assistant performs the function $f$ and the illusionist performs the inverse $f^{-1}$. As per the problem requirements, both $f$ and $f^{-1}$ need to be computable in poly(n) time for a given input. We note that given such an $f$, computing $f^{-1}$ is straightforward: given a covering $c$, we consider the compatible permutations. Among these, we choose the $\pi$ such that $f(\pi) = c$.
For $n = k! + k - 1$ we note that $|S_n| = |C_{n,k}| = n!\,$. We also note that each permutation is compatible with exactly $k!$ coverings and each covering is compatible with exactly $k!$ permutations. As OP mentioned, the Hall marriage theorem thus implies that a solution exists. We can find such a solution using a maximum matching algorithm on the bipartite graph. This is how @orlp found a solution for $k=3$ in the comments. However, the maximum matching algorithm computes $f$ for every permutation in poly(n!) time, where we instead need to compute $f$ for a single permutation in poly(n) time.
