Approach koyumeishi さんの IP Solver でこれScreenshot_2019-07-28 TopCoder Forums
が出来るようになったのでやってみた。もう1つは、2箇所変更して、有効な状態を見つけるまでを1回の遷移とするSimulated Annealingです。目安は1位のeldidouさんです。

NIP1時間(最適解)1位の eldidou さんSA
8212121
9262626
10333333
11393939
12464646
13535353
14636363
15717171
16818182
17919192
18103103103
19114114115
20127127128
21139139140
22153153155
23167167169
24182182184
25197197200
26213214217
27230231233
28247248251
29265266269
30284285287
31303304307
32323324329
33344350
34
366371
35386388393
36
411415
37431434440
38
458464
39479482489
40504508513
41
532538
42
559568
43
585596
44
613623
45
641650
46
670683
47
699711
48
730740
49
760773
50
791806
51
823838
52
855869
53
889904
54
922941
55
957976
56
9911006
57
10271044
58
10631083
59
10991120
60
11371155
61
11751198
62
12161233
63
12531278
64
12951320
65
13351357
66
13781401
67
14181443
68
14611489
69
15021529
70
15471580
71
15911622
72
16381673
73
16821716
74
17311762
75
17801810
76
18251858
77
18741912
78
19231960
79
19692008
80
20212060
81
20742111
82
21242167
83
21762211
84
22302272
85
22812322
86
23352386
87
23902438
88
24472490
89
25022550
90
25552608
91
26152662
92
26752724
93
27322780
94
27892848
95
28512911
96
29122961
97
29673029
98
30323098
99
30983158
100
31533222


source code (IP)

from __future__ import print_function
from ortools.linear_solver import pywraplp
from functools import reduce
import sys
import time
import codecs

class MovingNQueens:
    def find2(self, N):
        solver = pywraplp.Solver('SolveIntegerProblem',
            pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)

        center = N//2
 
        dy = [  0, -1, -1, -1,  0, 1, 1,  1 ]
        dx = [ -1, -1,  0,  1,  1, 1, 0, -1 ]

        x = [solver.IntVar(0.0, 1.0, 'x_{}_{}'.format(i//N, i%N)) for i in range(N*N)]

        constraints = []
        for i in range(N):
            column = solver.Constraint(1, 1)
            for j in range(N):
                column.SetCoefficient(x[i * N + j], 1)
            constraints.append(column)

        for j in range(N):
            row = solver.Constraint(1, 1)
            for i in range(N):
                row.SetCoefficient(x[i * N + j], 1)
            constraints.append(row)

        for j in range(N):
            i = 0
            diagonal = solver.Constraint(0, 1)
            for l in range(N):
                ni = i + l
                nj = j + l
                if ni>=N or nj>=N:
                    break
                diagonal.SetCoefficient(x[ni * N + nj], 1)
            constraints.append(diagonal)
        for i in range(1,N):
            j = 0
            diagonal = solver.Constraint(0, 1)
            for l in range(N):
                ni = i + l
                nj = j + l
                if ni>=N or nj>=N:
                    break
                diagonal.SetCoefficient(x[ni * N + nj], 1)
            constraints.append(diagonal)

        for j in range(N):
            i = N-1
            diagonal = solver.Constraint(0, 1)
            for l in range(N):
                ni = i - l
                nj = j + l
                if ni<0  or nj>=N:
                    break
                diagonal.SetCoefficient(x[ni * N + nj], 1)
            constraints.append(diagonal)
        for i in range(N-1):
            j = 0
            diagonal = solver.Constraint(0, 1)
            for l in range(N):
                ni = i - l
                nj = j + l
                if ni<0  or nj>=N:
                    break
                diagonal.SetCoefficient(x[ni * N + nj], 1)
            constraints.append(diagonal)

        objective = solver.Objective()
        for i in range(N):
            for j in range(N):
                objective.SetCoefficient(x[i * N + j], max(abs(i - center), abs(j - center)) )

        objective.SetMinimization()

        solver.set_time_limit(60*60*1000)

        start_time = time.time();
        result_status = solver.Solve()
        end_time = time.time();

        if result_status == pywraplp.Solver.OPTIMAL:
            print("{} {}".format("optimal.", solver.Objective().Value()), file=sys.stderr)
        else:
            print("time out.", file=sys.stderr)

        print("time = {} [sec]".format(end_time - start_time), file=sys.stderr)

        row_column = "/* " + str(N) + " " + ("opt" if result_status == pywraplp.Solver.OPTIMAL else "") + " " + str(solver.Objective().Value()) + "*/ {"
        for i in range(N):
            for j in range(N):
                z = i * N + j;
                if x[z].solution_value() == 1:
                    row_column += str(j) + ","
        row_column += "}"
        print("{}".format(row_column), file=codecs.open('./debug.txt', 'a+', 'utf-8'))

mnq = MovingNQueens()
for i in range(8,101):
    ret = mnq.find2(i)