题解 | #MP3光标位置#
MP3光标位置
https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15
def xx(a, n): flag = 1 #光标位置 k = 1 #当前歌曲位置 r = 4 #屏幕歌曲数量 if n < 4: r = n for i in a: if i == "D": if k == n: k = 1 flag = 1 elif flag != r: k += 1 flag += 1 else: k += 1 if i == "U": if k == 1: k = n flag = r elif flag != 1: k -= 1 flag -= 1 else: k -= 1 li = " ".join(str(k + i - flag + 1) for i in range(r)) print(li) print(k) while True: try: n = int(input()) a = input() xx(a, n) except: break