I was attempting this problem :
https://mirror.codeforces.com/contest/706/problem/D
I tried using trie and it gives TLE. I saw solutions of other people but most of them have created a TRIE by using struct and pointers. I have done it using a 2d next array following the idea from Errichto topic video of trie. I cant figure out why there is TLE, maybe because of map ? Any help would be appreciated.
Here is my code :
D
UPD Got accepted!
Thanks!