import sys
def main():
lines = sys.stdin.read().splitlines()
T = len(lines)
ret = []
idx = -1
for _ in range(T):
idx += 1
s = lines[idx]
n = len(s)
st = []
for i in range(n):
if len(st) == 0:
st.append(s[i])
continue
if s[i] == "o":
if st[-1] == "o":
st[-1] = "O"
if len(st) != 1 and st[-2] == "O":
st.pop()
st.pop()
else:
st.append("o")
else:
if st[-1] == "O":
st.pop()
else:
st.append("O")
ret.append(''.join(st))
sys.stdout.write("\n".join(ret))
if __name__ == "__main__":
main()
多组测试用例



京公网安备 11010502036488号