C++ O(nlogn) solution with comments. BFS + Floodfill + BST optimization
\nclass Solution {\npublic:\n    // Returns a range that pivot can be possibly at after reversing a subarray with length k.\n    inline pair<int, int> getRange(
```\nclass Solution {\npublic:\n    // Returns a range that pivot can be possibly at after reversing a subarray with length k.\n    inline pair<int, int> getRange(int n, int pivot, int k) {\n\t\t// Left most subarray containing pivot\n        int l1 = max(0, pivot - k + 1);\n        int r1 = l1 + k - 1;\n\t\t\n\t\t// Right most subarray containing pivot\n        int r2 = min(n - 1, pivot + k - 1);\n        int l2 = r2 - k + 1;\n\t\t\n\t\tint left = r1 - (pivot - l1);\n        int right = l2 + (r2 - pivot);\n        return {left, right};\n    }\n    \n    vector<int> minReverseOperations(int n, int p, vector<int>& banned, int k) {\n        unordered_set<int> bans(banned.begin(), banned.end());\n        vector<int> ans(n, -1);\n        // BST to store all nodes not visited yet.\n        set<int> s[2];\n\n        ans[p] = 0;\n        // Put all available postions in BST, split by parity\n        for (int i = 0; i < n; i ++)\n            if (i != p && bans.find(i) == bans.end())\n                s[i & 1].insert(i);\n        \n        // Queue for BFS floodfill.\n        queue<int> q;\n        q.push(p);\n        while (!q.empty()) {\n            int pivot = q.front();\n            q.pop();\n            auto range = getRange(n, pivot, k);\n\n            // for current pivot, check if it will visit even positions or odd positions. \n            int o = (k % 2 == 0) ? (1 - pivot & 1) : (pivot & 1);\n            //int o = (k & 1) ^ (pivot & 1) ^ 1;\n\n            // Find all reachable indexes range on the tree.\n            auto bg = s[o].lower_bound(range.first);\n            auto ed = s[o].upper_bound(range.second);\n\n            // Visit reachable indexes and update answer.\n            for (auto it = bg; it != ed; it ++) {\n                ans[*it] = ans[pivot] + 1;\n                q.push(*it);\n            }\n\n            // Remove visited indexes from tree.\n            s[o].erase(bg, ed);\n        }\n\n        return ans;\n    }\n};\n```
[]