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 »

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 »

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 »

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 »

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 »

Thank you brianfry713!
Post Reply

Return to “Volume 121 (12100-12199)”