nq1s788

24 минимальная ровно 3 X

Mar 21st, 2026
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. s = open('').readline()
  2. cnt_x = 0
  3. l = 0
  4. r = 0
  5. while cnt_x == 0:
  6.     l += 1
  7.     r += 1
  8.     if s[l] == 'X':
  9.         cnt_x += 1
  10. answ = 1000000000
  11. while r < len(s):
  12.     while r < len(s) and cnt_x != 3:
  13.         r += 1
  14.         if r < len(s) and s[r] == 'X':
  15.             cnt_x += 1
  16.     answ = min(answ, r - l + 1)
  17.     l += 1
  18.     while s[l] != 'X':
  19.          l += 1
  20.     cnt_x -= 1
  21. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment