Was getting nzec and wa earlier due to I/O related issues.
AC now. Thanks to simes for bearing with me.
created
last reply
- 24
replies
- 1.7k
views
- 2
users
Was getting nzec and wa earlier due to I/O related issues.
AC now. Thanks to simes for bearing with me.
I don’t know Java, but I had the same kind of problem when coding with Free Pascal.
I discovered that all the newing of trie nodes was relatively slow. So now when I use a trie, I create a static array of trie nodes, and allocate the elements of that array instead of newing them. I just keep a variable with the last used index.
YMMV.
Sure, that was easy. I have already tried everything i can think of . It’s just a simple trie implementation so I don’t know what is so wrong with my code. I even stored all the matching strings at each level for easy debugging but I couldn’t find any issue. Can you check if question wants me to print in some other format maybe related to newlines or spaces.
But do you need to ignore the exception? Can’t you re-throw it? or throw another? At least then you’d know something was not as you expected.
Length of all words <10^6 tells you how many trie elements you need.
The output format looks ok to me. Are you removing the line feed after the final test case? There’s no need to.
After removing return, spoj did give a nzec. I will try to see why now. Can it be related to heap space for java. I also removed the extra list of words that i had introduced for devugging . It did reduce the memory consumption 10 times but still runtime error (NZEC) .
But in other questions this has happened too when I used this method of i/o . And after just returning , i used to get AC. Like CSTreet and other questions. Still I will try some far fetched test cases.