boolean safe(int r, int c, int n, int[] occ) {
        for (int i = 0; i <= r; ++i) {
            if(occ[i] == c || Math.abs(occ[i]+i)==Math.abs(r+c) || occ[i]-i==c-r) {
                return false;
            }
        }
        return true;
    }