12103 - Leonardo's Notebook

All about problems in Volume 121. 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
sanmar1
New poster
Posts: 3
Joined: Sun Oct 26, 2014 8:49 pm

12103 - Leonardo's Notebook

Post by sanmar1 » Mon Oct 27, 2014 1:56 am

Can anybody please give me any hints to solve this problem? Thank you!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12103 - Leonardo's Notebook

Post by brianfry713 » Wed Oct 29, 2014 11:50 pm

Calculate the length of each permutation cycle.
If there is an odd number of an even length permutation cycle, then print No, otherwise Yes.
Check input and AC output for thousands of problems on uDebug!

sanmar1
New poster
Posts: 3
Joined: Sun Oct 26, 2014 8:49 pm

Re: 12103 - Leonardo's Notebook

Post by sanmar1 » Sat Nov 01, 2014 2:02 am

Thank you for your reply brianfry713. Can you please explain though, why "If there is an odd number of an even length permutation cycle, then print No, otherwise [print] Yes."
Thanks!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12103 - Leonardo's Notebook

Post by brianfry713 » Thu Nov 06, 2014 12:36 am

Consider string BA, it has one permutation cycle of length two, so there is no permutation you could apply twice to transform it to string AB.
However string BADC which has two permutation cycles of length two could be transformed to ABCD (via DCAB) using permutation 2310.
Check input and AC output for thousands of problems on uDebug!

sanmar1
New poster
Posts: 3
Joined: Sun Oct 26, 2014 8:49 pm

Re: 12103 - Leonardo's Notebook

Post by sanmar1 » Fri Nov 07, 2014 7:14 am

Thank you brianfry713!

Post Reply

Return to “Volume 121 (12100-12199)”