This is the case. You need to determine whether there is a solution for the 15th digital.
I won't. I found this method.
Store 16 numbers in one-dimensional arrays in order of appearance,
Then accumulate the number of reverse pairs of each number,
Add the distance from 0 to the final state of Manhattan to get a number X.
Due to the final state, the number of Reverse Order pairs for the entire graph is 15,
Is an odd number, so if X is also an odd number,
Then there will be solutions for this 15 digital,
Otherwise, no solution is available.
All other digital products follow this method,
My code is as follows:
# Include <iostream> using namespace STD; int main () {int map [16], ANS = 0; For (INT I = 0; I <16; I ++) {scanf ("% d", & map [I]); If (! Map [I]) ans + = 6-i % 4-I/4; for (Int J = 0; j <I; j ++) if (Map [J]> map [I]) ans ++;} If (ANS & 1) printf ("yes"); elseprintf ("no ");}