Created
May 21, 2025 13:34
-
-
Save neizod/bc91b5f3f49e6e7099e53b2dd45f631f to your computer and use it in GitHub Desktop.
A2-019, TOI-Zero: กระต่ายน้อยรัก BUU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
def yes(words): | |
return f'Yes {max(map(len, words))-1}' | |
def abuuu(word, i): | |
return (word[:i+1] + (len(word)*'U'))[:len(word)] | |
def buubu(word): | |
rep = 1 + len(word)//3 | |
return (rep*'BUU')[:len(word)] | |
def calc(word): | |
words = re.findall(r'bu{2,}', word, re.IGNORECASE) | |
if words: | |
return yes(words) | |
i = word.lower().find('b') | |
if i >= 0: | |
return abuuu(word, i) | |
return buubu(word) | |
print(calc(input().strip())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment