11084 - Anagram Division

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

Moderator: Board moderators

kalinov
New poster
Posts: 27
Joined: Tue Mar 29, 2005 3:10 pm
Location: Croatia

next_permutation

Post by kalinov »

fh wrote:the first thing i did was next_permutation(), but TLE
I got accepted in 5 sec by writing my own next_permutation procedure that calculates new remainder on the fly.

Also you can precalculate mod[x] = x mod d; up to 1000000 or so, to get rid of expensive mod operation.
Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian »

Hey thanks, I got rid of mod but by using substraction (in my algorithm is safe to just substract d from the new modulo if it is greater than or equal to d instead of just using mod) I saved 0.2 seconds, it still doubles the first place's time though.
mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari »

hi everybody , can any one explain the algorithm of this problem with a example......
thnkx......
Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian »

Now that the input changed it seems a lot of the people who used to have AC got Runtime Errror, including me.
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

The change is that d is now 10000 as promised by the problem statement instead of 1000, so my code get RE. So I'm basically forced to change the way I memorize values.
Post Reply

Return to “Volume 110 (11000-11099)”