Problem link:1785D - Деревянная ложка
First, WLOG we can assume we arrange the tournament in such way: In the every match, the left player wins. We can achieve this by doing the following operation to the binary tree of the tournament: for each non-leaf node of the binary tree, if the winner of this node is its right child, swap its left subtree and right subtree. Since fliping doesn't change the winner of each match, this will not change the "wooden spoon", and after this operation, the "wooden spoon" is the right-most node. Since there are 2^n-1 nodes in the binary tree, we can merge 2^(2^n-1) situations into one by this operation.
For example, we can do operation to this tree:
_________1
_____3_______1
-__5___3___1___2
__7_5_3_6_1_8_4_2
-->
_________1
_____1_______3
-__1___2___3___5
__1_8_2_4_3_6_5_7
Where 1 (the left-most node) is the champion, and 7 (the right-most node) is the "wooden spoon".
Then we assume the right-most node is k, and there's dp[n][k] different arrangements (after operation). If k is the j-th smallest element in the right half of the tree, then we have sum(i=1...2^(n-1))(dp[n-1][i]) ways to arrange the left half, and dp[n-1][j] ways to arrange the right half (since k is also the right-most node in the right-subtree). But in how many ways we can distribute 2^n elements into 2 halves? Well, since 1 is the left-most element, there are k-2 elements we could put in the right part (which are in the range [2, k-1]), and there are actually j-1 elements of them in the right part, so we have C(k-2,j-1) ways to choose them. Similarly, we have C(2^n-k, 2^(n-1)-j) ways to choose elements from [k+1, 2^k]. Therefore, we can get such formula:
dp[n][k]=sum(i=1...2^(n-1))(dp[n-1][i])*dp[n-1][j]*C(k-2,j-1)*C(2^n-k,2^(n-1)-j)
Then we can calculate them by FFT. The answer is 2^(2^n-1)*dp[n][k].