题解 | #MP3光标位置#
MP3光标位置
https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15
n =int(input()) m =input() s =[i for i in range(1,n+1)] idx=0 st=0 ed=4 if n <=4: idx=(m.count('D')-m.count('U')+abs(m.count('D')-m.count('U'))*n)%n st=0 ed=4 else: for i in m: if i=='U': idx-=1 if idx<0: idx+=n st=n-4 ed=n continue if idx>=st: continue else: st -=1 ed -=1 if i =='D': idx +=1 if idx>=n: idx -=n st=0 ed=4 continue if idx< ed: continue else: st +=1 ed +=1 k=s[st:ed] print(' '.join(list(map(str,k)))) print(s[idx])