题解 | #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])

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 11:55
点赞 评论 收藏
分享
星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务