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
vinay
Experienced poster
Posts: 104 Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:
Post
by vinay » Sun Oct 15, 2006 2:56 pm
what algo to use ...
I think somee dp...
any hint about it and the algo complexity...
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 » Wed Oct 18, 2006 2:16 am
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 » Wed Oct 18, 2006 2:23 am
some one hhelp on this topic...
no reponses yet
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 » Wed Oct 18, 2006 2:24 am
I'll try backtracking.
vinay
Experienced poster
Posts: 104 Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:
Post
by vinay » Wed Oct 18, 2006 2:27 am
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 » Wed Oct 18, 2006 2:52 am
I got AC.
Whether or not you get TLE will depends how fast you can do the following.
Input:
Output:
vinay
Experienced poster
Posts: 104 Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:
Post
by vinay » Wed Oct 18, 2006 3:33 am
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
Post
by rushel » Wed Oct 18, 2006 8:37 am
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 » Wed Oct 18, 2006 5:46 pm
it tle's.....
here is my code...
how can i improve upon it??
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 » Wed Oct 18, 2006 7:40 pm
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 » Wed Oct 18, 2006 8:07 pm
thanks ...
its AC in 1.682 secs..
strings are really very slow....
i need to minimize thrie usage
If I will myself do hashing, then who will do coding !!!
coolguy
New poster
Posts: 30 Joined: Tue Oct 17, 2006 5:59 pm
Post
by coolguy » Thu Jan 04, 2007 1:39 am
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
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 » Thu Jan 04, 2007 3:10 pm
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.
coolguy
New poster
Posts: 30 Joined: Tue Oct 17, 2006 5:59 pm
Post
by coolguy » Fri Jan 05, 2007 3:25 am
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