Have received Time Limit Exceeded.
My algo:
1. create the tree.
2. BFS traversal. Pushed the elements into string as the elements are visited.
3. reversed the string.
I checked the Judges's comment from the original source http://www.informatik.uni-ulm.de/acm/Locals/2007/.
My algo seems similar.
I ran on the test case mentioned there(200 test cases).
To test the timing(using clock()) I tried two approach:
a) instead of writing on console I wrote on file.
b) wrote on console.
Code: Select all
if (WRITE_INTO_FILE)
{
fprintf(pFile,"%s\n",str.c_str());
}
else
{
printf("%s\n",str.c_str());
}
Timing in case(a):
Total time: 297 ms.
Individual timing: usually 0 except for some cases its 15-16 ms.
Timing in case(b):
Total time: 6.36 sec
Any idea what should I change?