思路感觉没错,相邻的 1 会合并为一个操作,相邻的 2 如果偶数个不操作,奇数个变一下,但还是超时, 45% N, M = [int(_) for _ in sys.stdin.readline().strip().split()] t_ls = [int(_) for _ in sys.stdin.readline().strip().split()] P = [str(_) for _ in range(1, N+1)] i = 0 while i < M: if t_ls[i] == 1: count = 0 while i < M and t_ls[i] == 1: count += 1 i += 1 count = count % N if count != 0: P = P[count:] + P[:count] else: count = 0 while i < M and t_ls[i] == 2: count += 1 i += 1 if count % 2 == 1: for j in range(0, N, 2): P[j], P[j+1] = P[j+1], P[j] print(" ".join(P))
点赞 2

相关推荐

不愿透露姓名的神秘牛友
07-08 12:10
点赞 评论 收藏
分享
星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
Twilight_m...:经典我朋友XXXX起手,这是那种经典的不知道目前行情搁那儿胡编乱造瞎指导的中年人,不用理这种**
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务