Need help regarding max XOR of all elements of sub-rectangular grid of 2d grid

Revision en1, by cseshamim47, 2024-03-05 10:02:06

Given a 2d array of N * M, find the max XOR of all elements of a sub-matrix. Problem Link.

N <= 10000 and M <= 20. Time limit: 1s. Memory limit: 256

I tried to go through all possible subarray [l...r] on M and calculated its xor. Then for each [l...r] I traversed all rows and then calculated the max xor of this [l...r]*Ni rectangle using trie.

When trie is implemented using struct I'm getting TLE. But, array implementation of trie is giving Accepted verdict. I don't understand what's the difference in time complexity. Isn't it the same?

TLE Solution
AC Solution

Also, I see that somebody has solved it without trie. How to solve it without trie?

Without TRIE solution
Tags trie, xor subarray, help me

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English cseshamim47 2024-03-05 10:02:06 5556 Initial revision (published)