public int move(int r, int c, int player) {
            int n = rows.length;
            if (player == 1) {
                ++rows[r]; ++cols[c];
                if (r == c) ++d1;
                if (r + c + 1 == n) ++d2;
            } else {
                --rows[r]; --cols[c];
                if (r == c) --d1;
                if (r + c + 1 == n) --d2;
            }
            if (Math.abs(rows[r]) == n ||
                Math.abs(cols[c]) == n ||
                Math.abs(d1) == n ||
                Math.abs(d2) == n) return player;
            return 0;
        }