Codeforces Round #395 (Div. 2)B. Timofey and cubes
地址:http://codeforces.com/contest/764/problem/B
题目:
1 second
256 megabytes
standard input
standard output
Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, 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.
The first line contains single integer n (1 ≤ n ≤ 2·105) — the number of cubes.
The second line contains n integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109), where ai is the number written on the i-th cube after Dima has changed their order.
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.
7
4 3 7 6 9 1 2
2 3 9 6 7 1 4
8
6 1 4 2 5 6 9 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].
思路:水题,看代码即可
代码
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int n,a[K];
int main(void)
{
cin>>n;
for(int i=;i<=n;i++)cin>>a[i];
for(int i=;i<=n-i+;i++)
if(i&)
swap(a[i],a[n-i+]);
for(int i=;i<=n;i++)
printf("%d ",a[i]); return ;
}
Codeforces Round #395 (Div. 2)B. Timofey and cubes的更多相关文章
- Codeforces Round #395 (Div. 2) D. Timofey and rectangles
地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 s ...
- Codeforces Round #395 (Div. 2) C. Timofey and a tree
地址:http://codeforces.com/contest/764/problem/C 题目: C. Timofey and a tree time limit per test 2 secon ...
- 【分类讨论】Codeforces Round #395 (Div. 2) D. Timofey and rectangles
D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都 ...
- 【树形DP】Codeforces Round #395 (Div. 2) C. Timofey and a tree
标题写的树形DP是瞎扯的. 先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结 ...
- Codeforces Round #297 (Div. 2)E. Anya and Cubes 折半搜索
Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #395 (Div. 2)(A.思维,B,水)
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- Codeforces Round #395 (Div. 2)(未完)
2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...
- Codeforces Round #395 (Div. 2)
今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内 两个序列 n,2*n,3*n...... ...
- Codeforces Round #395 (Div. 2) D
Description One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On t ...
随机推荐
- dedecms安全篇:织梦文件夹目录权限设置
织梦各个目录安全详解 做织梦(dedecms)网站安全必看1.a 因为是静态目录,并且在要生成HTML的,所以拒绝脚本执行 允许写入2.data 因为是缓存等,所以充许写入,但是因为这里面 ...
- 第一百四十一节,JavaScript,封装库--DOM加载
JavaScript,封装库--DOM加载 DOM加载,跨浏览器封装DOM加载,当网页文档结构加载完毕后执行函数,不等待图片音频视频等文件加载完毕 /** dom_jia_zai()函数,DOM页面加 ...
- 嵌入式驱动开发之spi---spi串口通信调试
一. 概念 SPI是 Serial Peripheral Interface(串型外部接口)的缩写.SPI接口有4根PIN脚,分别是: * SPICLK : 用于传输数据的同 ...
- 多线程之使用读写锁ReentrantReadWriteLock实现缓存系统
简单地缓存系统:当有线程来取数据时.假设该数据存在我的内存中.我就返回数据.假设不存在我的缓存系统中,那么就去查数据库.返回数据的同一时候保存在我的缓存中. 当中涉及到读写问题:当多个线程运行读操作时 ...
- ubuntu卸载vmware player
sudo vmware-installer -u vmware-player 转自: http://zhidao.baidu.com/link?url=lapkBNBGIUz_mo6603CQgi_2 ...
- 进度条在.net导入Excel时的应用实例
这篇文章主要介绍了进度条在.net导入Excel时的应用,以实例形式讲述了.net导入Excel时根据页面情况显示进度条的实现方法,非常具有实用价值,需要的朋友可以参考下 本文实例讲述了进度条在.ne ...
- Python调用外部程序
通过os.system和subprocess.call()函数调用其他程序 预备知识:cmd中打开和关闭程序 cmd中打开程序 a.打开系统自带程序 系统自带的程序的路径一般都已加入环境变量之中,只需 ...
- python 保存csv文件
利用pandas库, 将numpy的array数据保存成csv格式的文件: import pandas as pd import numpy as np data = pd.read_csv('C:\ ...
- LINQPad_批量修改图片名称
用到这个工具是在后台批量修改图片名称的时候 下载并安装LINQPad. 这里要注意:在复制path路径的时候C:\xampp\htdocs\day01\angularjs_day01_am\angul ...
- java pdf 导出方案
java代码 import com.itextpdf.text.DocumentException; import com.itextpdf.text.pdf.BaseFont; import org ...