% blocked n-queens
int: n; % size of board (n x n)
set of int: ROW = 1..n;
set of int: COL = 1..n;
int: m; % number of blocked positions
set of int: BLOCK = 1..m;
array[BLOCK] of COL: col;
array[BLOCK] of ROW: row;
array[ROW] of var COL: q; % which col queen is on row i
include "alldifferent.mzn";
constraint alldifferent(q);
constraint alldifferent([ q[i] + i | i in ROW ]);
constraint alldifferent([ q[i] - i | i in ROW ]);
constraint forall(b in BLOCK)
(q[row[b]] != col[b]);
solve satisfy;
output [ "queen(\(i), \(q[i])).\n" | i in ROW ];