Codeforces: Queens, Again
check features a well-known anti-idiom:

if (condition) {
    return false;
}
return true;


is a long way to say

return !condition;

Testing for j == N - 1 in a loop looks unappealing. The code would be much cleaner if the inner loop (which actually decides on the problem) were factored out into a function:

bool is_position_valid(....)
{
    ....
    for (int j = 0; j &lt; N; j++) {
        if (check(....)) {
            paint(....);
        } else {
            return false;
        }
    }
    return true;
}


and the caller produced the required output.
The complexity is quadratic in both time and space. There is a way to drive the down to linear: have 4 arrays of sizes N, N, 2*N - 1, 2*N - 1 (for files, ranks, and left and right diagonals respectively), and for each queen mark a corresponding entry as taken; if the entry is already taken the position is invalid.