11127 - Triple-Free Binary Strings

All about problems in Volume 111. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

11127 - Triple-Free Binary Strings

Post by vinay »

what algo to use ...

I think somee dp...

any hint about it and the algo complexity... :oops:
If I will myself do hashing, then who will do coding !!!
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

I can't see the dp yet. Can it be backtracking?
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

some one hhelp on this topic...

no reponses yet :cry:
If I will myself do hashing, then who will do coding !!!
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

I'll try backtracking.
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

do respond if accepted...

thanks in advance..
:)
If I will myself do hashing, then who will do coding !!!
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

I got AC. :D
Whether or not you get TLE will depends how fast you can do the following.
Input:

Code: Select all

30 ******************************
Output:

Code: Select all

Case 1: 230800
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

what is ur algo...???
If I will myself do hashing, then who will do coding !!!
rushel
Learning poster
Posts: 67
Joined: Sat Jan 22, 2005 5:57 am

algo

Post 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
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

it tle's.....
here is my code...

how can i improve upon it??

Code: Select all

edit: ACC  :) 
Last edited by vinay on Wed Oct 18, 2006 8:06 pm, edited 1 time in total.
If I will myself do hashing, then who will do coding !!!
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post 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.
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

thanks ...
its AC in 1.682 secs..

strings are really very slow....
i need to minimize thrie usage :lol:
If I will myself do hashing, then who will do coding !!!
coolguy
New poster
Posts: 30
Joined: Tue Oct 17, 2006 5:59 pm

getting TLE

Post 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 :wink: CODE DELETED

thank you
Last edited by coolguy on Fri Jan 05, 2007 3:27 am, edited 1 time in total.
In good company
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post 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:

Code: Select all

Case 1: 0
You will see the output instantly if your code is alright.
Ami ekhono shopno dekhi...
HomePage
coolguy
New poster
Posts: 30
Joined: Tue Oct 17, 2006 5:59 pm

about tle in 11127 triple binary string

Post 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
In good company
Post Reply

Return to “Volume 111 (11100-11199)”