Hello everyone!
Here we go again.. writing a solution to a problem which supposedly works on my PC but delivers runtime error on the codeforces server.
The submission I'm talking about is this: 19567131. I've been reading about suffix trees and trying to solve a simple problem. The solution is pretty lengthy, but... Does anyone know what error code 255 is? I also tried custom tests and occasionally I get error code -1073741819. I compile under gcc 5.1.0 — the same as codeforces I think, using c++11. I tried using flags "-std=c++11 -Wextra -pedantic -Wall -O2" but didn't get anything interesting. I've been playing around with this for quite a while now, but I can't seem to get it to work.
I'd be grateful for any help anyone can provide!
At least one of the problems is that you don't zero-initialize your
child
array.This is what crashed my application, thanks alot!
However, now I'm getting memory limit exceeded (19572966). I'm guessing memory leak, and I've managed to fix it somewhat by reducing alphabet size and adding delete on some parts of the code but I'm still getting MLE, this time on test 51 (19573167). Also, the code is getting pretty close to the time limit as well...
Theory says that there shouldn't be more than 2m nodes in the suffix tree so if I'm calculating correctly, it should pass for memory limit. Also, the algorithm should be O(m) which should be pretty fast..
This means there must be something wrong with my code, I'll keep trying
I think it might be this way:
All other warnings are about using chars as SuffixNode ans vice versa
Hope it help :3
I've already seen these errors but I don't think it matters if I use char as index. Same for this initializer order (though I fixed that one)
Debugger also said that program crashes on line 70
You should check it when global var SuffixTree tree initialized
Yes! This combined with slycelotes comment really helped. Turned out the child[] array wasn't initialized to nullptr so the if(..child[i]!=nullptr) passes even though there's no SuffixNode object there.