Map of queue values memory overhead

Revision en1, by paxaq, 2026-08-04 07:28:59

I was solving 2247D1 - XOR Sorting (Easy Version). My solution is as follows: for each number in the array, take the XOR of its original index and its index in the (in-place) sorted array; the answer is the largest power of two that is smaller than the maximum of these XORs. Here are two submissions that implement this logic: 385482647 385482343. The first one passes fine but the second one gives MLE. The only difference is in how I find the second index. In the first one, I just use some sorting trick. In the second one, I maintain a map<int, queue<int>> from numbers to the queue of indices. Is the overhead that large to cause MLE or am I missing something else?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English paxaq 2026-08-04 07:28:59 722 Initial revision (published)