Page 1 of 1
11127 - Triple-Free Binary Strings
Posted: Sun Oct 15, 2006 2:56 pm
by vinay
what algo to use ...
I think somee dp...
any hint about it and the algo complexity...

Posted: Wed Oct 18, 2006 2:16 am
by sclo
I can't see the dp yet. Can it be backtracking?
Posted: Wed Oct 18, 2006 2:23 am
by vinay
some one hhelp on this topic...
no reponses yet

Posted: Wed Oct 18, 2006 2:24 am
by sclo
I'll try backtracking.
Posted: Wed Oct 18, 2006 2:27 am
by vinay
do respond if accepted...
thanks in advance..

Posted: Wed Oct 18, 2006 2:52 am
by sclo
I got AC.

Whether or not you get TLE will depends how fast you can do the following.
Input:
Output:
Posted: Wed Oct 18, 2006 3:33 am
by vinay
what is ur algo...???
algo
Posted: Wed Oct 18, 2006 8:37 am
by rushel
Its a simple backtracking and u have to check triples efficienty.
suppose u have string S so far in backtracking and s is a suffix of S and |s| should be multiple of 3. use this idea.
thanks
Posted: Wed Oct 18, 2006 5:46 pm
by vinay
it tle's.....
here is my code...
how can i improve upon it??
Posted: Wed Oct 18, 2006 7:40 pm
by sclo
the way that you use stl string makes it tle. You keep passing string as argument to your functions, which is slow. You don't need to pass any string as argument, just keep it simple and working directly with a char array is enough.
Posted: Wed Oct 18, 2006 8:07 pm
by vinay
thanks ...
its AC in 1.682 secs..
strings are really very slow....
i need to minimize thrie usage

getting TLE
Posted: Thu Jan 04, 2007 1:39 am
by coolguy
im getting TLE in this problem. any possible optimization u want me to consider. i used backtracking. here is the code:
GOT AC

CODE DELETED
thank you
Posted: Thu Jan 04, 2007 3:10 pm
by Jan
You are checking the validity after calculating a full sequence. Try to check the validity while calculating a sequence.
Input:
Code: Select all
30 000***************************
0
Output:
You will see the output instantly if your code is alright.
about tle in 11127 triple binary string
Posted: Fri Jan 05, 2007 3:25 am
by coolguy
Jan wrote:
You are checking the validity after calculating a full sequence.
this is not right. i did check for validity after putting every character. my problem was that i didn't check the validity efficiently. my code for checking the validity was naive, now i changed it and got ac in around 3 seconds. thank you anywayz for your reply Jan.
BYE