Please read the new rule regarding the restriction on the use of AI tools. ×

Problem 1389C — Good String.Is my logic wrong ?

Revision en1, by luizantonioprg, 2020-08-26 23:43:20

PROBLEM -> https://codeforces.me/problemset/problem/1389/C

I have been trying to solve this problem and my logic to try achieve that was:

Compare the Left Cyclic Array with the Right Cyclic Array.If both are equal,the array is good.If it doesn't check if the numbers of the input array are different.If they are,subtract the length by 2,because a good array would be a combination of just 2 items of them,such:

95381 -> 51

If there is a number duplicated in the input array,such (1,1,2,3,4,5); Count the number of occurrences of the most frequent number.Use this to subtract from array length. Example:(1,1,1,1,2,3);(4 occurences of the number "1") A Good String would be: 1111 . Array length = 6 => 6(length)-4(occurrences)="2".

In the first test,this worked.But in the second not. You can see my last submission in PHP: https://codeforces.me/submissions/luizantonioprg Is my logic wrong?

Tags php, good string

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English luizantonioprg 2020-08-26 23:45:49 6 Tiny change: 'irst test,this worked.Bu' -> 'irst test,it worked.Bu'
en1 English luizantonioprg 2020-08-26 23:43:20 959 Initial revision (published)