#5105. Subsegment Reverse

0
    ID: 5105 传统题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>AtCoderabc356AGESP 1级枚举(单层循环)分支结构

Subsegment Reverse

Subsegment Reverse

题目描述

You are given positive integers NN, LL, and RR.
对于长度为 NN 的序列 A=(1,2,…,N)A = (1, 2, \dots, N),对第 LL 个到第 RR 个元素执行了一次反转操作。
输出该操作后的序列。

输入格式

The input is given from Standard Input in the following format: NN LL RR

输出格式

Let A′=(A1′,A2′,…,AN′)A' = (A'_1, A'_2, \dots, A'_N) be the sequence after the operation. Print it in the following format: A1′A'_1 A2′A'_2 …\dots AN′A'_N

5 2 3
1 3 2 4 5
7 1 1
1 2 3 4 5 6 7
10 1 10
10 9 8 7 6 5 4 3 2 1

提示

All input values are integers. 1≤L≤R≤N≤1001 \leq L \leq R \leq N \leq 100Initially, A=(1,2,3,4,5)A = (1, 2, 3, 4, 5).
反转第二个到第三个元素后,序列变为 (1,3,2,4,5)(1, 3, 2, 4, 5),应当输出该序列。
可能存在 L=RL = R.
可能存在 L=1L = 1 或 R=NR = N.

标签: AtCoder|abc356A

来源

AtCoder|abc356A