Help in Codeforces Perfect Security Round470

codeforces
memory-limit
runtime-error
segmentation-fault
trie

#1

I’m getting runtime error (segmenation fault for n>250 on local compiler). I have used naive implementation of trie to solve the question. What’s wrong in my approach? Is this error due to consuming too much memory?

Code Link