Advertisement
Korotkodul

dem23.n24

Jun 17th, 2023 (edited)
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import sys
  2.  
  3. f = open('24.txt')
  4. s = f.readline()
  5. f.close()
  6.  
  7. def d(x,y):
  8.     global s
  9.     s = s.replace(x,y)
  10. x = 'CDF'
  11. y = 'AO'
  12. print(s[:20])
  13. for i in x:
  14.     d(i, 'X')
  15.     print(s[:20])
  16.  
  17. for i in y:
  18.     d(i,'Y')
  19.     print(s[:20])
  20.    
  21.  
  22. L = 1
  23. R = len(s)
  24. while L + 1 < R:
  25.     M = (L + R) // 2
  26.     if 'XY' * M in s:
  27.         L = M
  28.     else:
  29.         R = M
  30. print(L)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement