|
|
вернуться в форумFor everyone who thinks that his solution( C++ ) is correct, but has TLE.. Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE.. Послано fmm 20 июн 2010 05:32 i disagree, my solution takes 0.046 seconds... and i use string, vector Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE.. Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) STL string - TL 12, 10 MB used. Char arrays - AC 0.031, 1.24 MB used... Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE.. I got TLE. But after changing "s1.size()" on "long ns1 = s1.size()" and "s2.size()" on "long ns2" got AC. =) And I changed "vector" on "deque"( for deleting elements from begining ). Edited by author 14.12.2011 16:27 Edited by author 14.12.2011 16:30 Re: For everyone who thinks that his solution( C++ ) is correct, but has TLE.. Послано ASK 30 янв 2014 23:22 Got 0.062 and 1485 KB with pure STL and strings: just start your program with cin.sync_with_stdio(false); Btw, to get a O(n) solution consider that if a suffix of the last word is a prefix of the first word (check thru hash), then it is safe to assume that this suffix is in the answer. |
|
|