12103 - Leonardo's Notebook
Moderator: Board moderators
12103 - Leonardo's Notebook
Can anybody please give me any hints to solve this problem? Thank you!
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 12103 - Leonardo's Notebook
Calculate the length of each permutation cycle.
If there is an odd number of an even length permutation cycle, then print No, otherwise Yes.
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!
Re: 12103 - Leonardo's Notebook
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!
Thanks!
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 12103 - Leonardo's Notebook
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.
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!
Re: 12103 - Leonardo's Notebook
Thank you brianfry713!