CF764B.Timofey and cubes
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number a__i, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.
In this time, Timofey's elder brother, Dima reordered the cubes using the following rule. Suppose the cubes are numbered from 1 to n in their order. Dima performs several steps, on step i he reverses the segment of cubes from i-th to (n - i + 1)-th. He does this while i ≤ n - i + 1.
After performing the operations Dima went away, being very proud of himself. When Timofey returned to his cubes, he understood that their order was changed. Help Timofey as fast as you can and save the holiday — restore the initial order of the cubes using information of their current location.
今天是小提莫费的生日!他从父母那里收到了一份包含 n 个立方体的礼物。每个立方体上都写有一个数字 ai。提莫费将所有立方体排成一排,然后去拆其他礼物了。
就在此时,提莫费的哥哥迪马按照如下规则重新排列了这些立方体。假设这些立方体按其排列顺序编号为 1 到 n。迪马执行若干步操作:在第 i 步中,他将第 i 个到第 (n−i+1) 个立方体这一段进行翻转(即逆序)。他持续执行该操作,直到满足 i≤n−i+1 为止。
完成这些操作后,迪马非常自豪地离开了。当提莫费回到他的立方体旁时,发现它们的顺序已被改变。请尽快帮助提莫费,挽救这个节日——根据立方体当前的排列,还原出它们最初的顺序。
输入格式
The first line contains single integer n (1 ≤ n ≤ 2·105) — the number of cubes.
The second line contains n integers _a_1, _a_2, ..., a__n ( - 109 ≤ a__i ≤ 109), where a__i is the number written on the i-th cube after Dima has changed their order.
第一行包含一个整数 n(1≤n≤2⋅105)—— 立方体的数量。
第二行包含 n 个整数 a1,a2,…,an(−109≤ai≤109),其中 ai 表示在迪马调整顺序后,第 i 个立方体上所写的数字。
输出格式
Print n integers, separated by spaces — the numbers written on the cubes in their initial order.
It can be shown that the answer is unique.
输出 n 个整数(用空格分隔)——即立方体上最初写下的数字。
可以证明该答案是唯一的。
输入输出样例
输入#1
7 4 3 7 6 9 1 2
输出#1
2 3 9 6 7 1 4
输入#2
8 6 1 4 2 5 6 9 2
输出#2
2 1 6 2 5 4 9 6
说明/提示
Consider the first sample.
- At the begining row was [2, 3, 9, 6, 7, 1, 4].
- After first operation row was [4, 1, 7, 6, 9, 3, 2].
- After second operation row was [4, 3, 9, 6, 7, 1, 2].
- After third operation row was [4, 3, 7, 6, 9, 1, 2].
- At fourth operation we reverse just middle element, so nothing has changed. The final row is [4, 3, 7, 6, 9, 1, 2]. So the answer for this case is row [2, 3, 9, 6, 7, 1, 4].
考虑第一个样例。
- 初始行是 [2, 3, 9, 6, 7, 1, 4]。
- 第一次操作后,行为 [4, 1, 7, 6, 9, 3, 2]。
- 第二次操作后,行为 [4, 3, 9, 6, 7, 1, 2]。
- 第三次操作后,行为 [4, 3, 7, 6, 9, 1, 2]。
- 第四次操作中,我们仅翻转中间元素,因此行未发生任何变化。最终行为 [4, 3, 7, 6, 9, 1, 2]。因此本例的答案是初始行 [2, 3, 9, 6, 7, 1, 4]。
输入解题思路,AI测评打分。不知道怎么写?