Для проверки написал прогу близкую к предложенной
Sonic86. Сейчас железо помощнее нежели в девятом году - можно сделать больше оптимизаций на случайно сгенерированных данных. Для каждого
я делал по
проверок, вот результаты:
Код:
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17},{16,15,11,12,8,13,4,7,5,10,6,3,2,14,9,17,1},{17,13,12,8,10,5,14,7,9,4,6,11,15,2,3,1,16},6344}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18},{18,16,10,14,9,11,6,12,4,5,7,13,3,8,2,15,1,17},{17,14,15,8,10,7,11,5,13,9,6,3,12,4,16,2,18,1},7842}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19},{19,16,14,12,15,10,5,8,6,9,4,11,3,13,7,17,2,1,18},{18,17,13,11,7,9,15,8,10,6,12,4,14,3,5,2,16,19,1},9587}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},{20,18,16,14,8,9,11,15,10,4,6,5,12,3,7,13,2,17,1,19},{19,17,13,11,15,12,8,5,7,16,9,10,4,14,6,3,18,2,20,1},11610}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21},{20,19,15,12,14,17,6,8,13,9,7,5,4,10,16,11,3,2,18,21,1},{21,18,16,15,10,7,17,11,6,8,9,12,13,5,3,4,14,19,2,1,20},13933}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22},{22,20,18,14,13,11,12,6,15,5,9,17,7,8,3,10,16,4,2,19,1,21},{21,19,15,14,13,12,10,17,6,16,8,4,9,7,18,5,3,11,20,2,22,1},16592}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23},{22,21,19,12,15,14,13,9,17,5,6,11,8,16,4,7,18,3,10,2,20,23,1},{23,20,16,19,12,11,10,13,6,18,14,7,9,4,15,8,3,17,5,21,2,1,22},19612}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},{24,22,20,18,14,16,9,11,6,15,12,17,4,8,7,5,10,19,3,13,2,21,1,23},{23,21,17,14,15,11,16,12,19,7,8,5,20,9,10,13,6,3,18,4,22,2,24,1},23028}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25},{25,23,20,21,19,12,11,8,10,13,5,14,15,17,7,9,4,16,6,3,18,2,22,1,24},{24,22,19,14,12,16,15,18,13,9,21,7,6,5,11,8,17,4,10,20,3,23,2,25,1},26871}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26},{26,24,22,20,19,14,11,18,12,6,15,5,10,7,8,16,13,4,17,9,21,3,2,23,1,25},{25,23,19,16,14,15,17,9,12,21,8,22,10,13,11,5,6,18,4,7,3,20,24,2,26,1},31178}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27},{26,25,22,18,19,14,17,20,9,10,12,15,5,8,6,13,21,16,4,7,23,11,3,2,24,27,1},{27,24,22,20,15,17,12,9,18,14,11,8,23,13,16,7,4,5,19,10,3,6,21,25,2,1,26},35978}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28},{28,26,24,22,19,18,12,14,11,15,7,17,6,16,9,20,4,10,21,8,13,3,23,5,2,25,1,27},{27,25,22,18,17,15,19,14,16,11,21,8,20,7,12,5,23,9,4,10,6,24,3,13,26,2,28,1},41315}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29},{29,26,25,23,16,17,19,14,11,22,15,10,7,6,13,18,21,8,4,9,12,20,3,24,5,27,2,1,28},{28,27,24,19,22,17,13,16,18,8,11,15,20,21,9,6,5,12,23,10,7,4,25,3,14,2,26,29,1},47223}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},{30,28,26,22,24,18,13,20,11,15,16,7,8,14,9,17,19,12,21,4,23,6,5,10,3,25,2,27,1,29},{29,27,25,22,16,18,21,12,20,13,11,23,19,10,14,7,6,9,5,24,4,15,17,8,26,3,28,2,30,1},53739}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31},{30,28,27,24,25,23,16,17,20,10,8,22,13,11,7,15,5,12,19,6,9,14,4,18,21,3,26,29,2,31,1},{31,29,26,22,17,15,19,16,12,21,24,8,13,14,20,9,25,10,6,18,11,7,23,5,4,27,3,2,28,1,30},60910}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32},{32,30,28,25,20,23,22,16,13,18,12,14,11,21,7,24,15,5,6,17,10,26,4,8,19,9,3,27,2,29,1,31},{31,29,27,23,24,17,15,19,20,13,18,14,16,8,22,6,9,26,21,7,11,4,25,12,5,10,28,3,30,2,32,1},68776}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33},{33,30,28,26,27,20,16,19,13,21,23,8,11,14,12,10,17,24,5,18,15,6,22,7,25,9,4,29,3,31,2,1,32},{32,31,29,25,19,21,23,17,22,12,10,26,18,13,14,16,9,6,27,7,8,20,5,15,4,11,24,3,28,2,30,33,1},77377}
{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34},{34,32,30,28,24,21,25,13,15,20,14,9,19,16,11,22,7,17,10,23,26,18,12,6,4,27,8,5,3,29,2,31,1,33},{33,31,29,25,23,22,16,27,21,14,18,26,11,12,17,8,24,9,15,6,5,7,10,19,28,4,13,20,30,3,32,2,34,1},86763}