C-Style Strings vs. C++ Strings

Revision en2, by sw1ft, 2017-01-19 18:39:44

Hey everyone. Yesterday I found problem UVa 10679 — I Love Strings!!, solved it using C++ Strings and KMP, and got a runtime of 1.080/3.000s. I found this rather high so I looked for the problem on the web and found on Algorithmist that this problem perfectly suits Aho-Corasick, so I found this guide and solved the problem based on that, but I'm getting TLE. After this I was a little bit confused, but maybe such implementation is just slow. Then I checked the Problem Stats and found that morris821028's solution is ranked 17 with a runtime of 0.016, so I thought he must have implemented Aho-Corasick in a (much) faster way. Right after this I looked for his solution: turns out he used KMP, just like me, but with C-Style strings instead...

Are C-Style Strings really this faster or is this just an especial case?

Tags strings

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English sw1ft 2017-01-19 18:39:44 0 (published)
en1 English sw1ft 2017-01-19 18:39:10 1321 Initial revision (saved to drafts)