CF764 B. Timofey and cubes(水题)
来源:互联网 发布:优化驱动器有什么好处 编辑:程序博客网 时间:2024/05/16 09:46
传送门
题目大意:对于长度为n的序列的位置i,若i<n-i+1,则将i到n-i+1倒序一次。给出变换后的序列,求原序列。
解题思路:看第一个样例解释就很清楚了,实际上就是从两头开始往中间两两进行变换,注意变换的奇偶次数决定这对数最终是否有变换到。
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ *///#pragma comment(linker, "/STACK:102400000,102400000")#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <bitset>using namespace std;#define rep(i,a,b) for (int i=(a),_ed=(b);i<=_ed;i++)#define per(i,a,b) for (int i=(b),_ed=(a);i>=_ed;i--)#define pb push_back#define mp make_pairconst int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define LL long long#define ULL unsigned long long#define MS0(X) memset((X), 0, sizeof((X)))#define SelfType intSelfType Gcd(SelfType p,SelfType q){return q==0?p:Gcd(q,p%q);}SelfType Pow(SelfType p,SelfType q){SelfType ans=1;while(q){if(q&1)ans=ans*p;p=p*p;q>>=1;}return ans;}#define Sd(X) int (X); scanf("%d", &X)#define Sdd(X, Y) int X, Y; scanf("%d%d", &X, &Y)#define Sddd(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())#define all(a) a.begin(), a.end()#define mem(x,v) memset(x,v,sizeof(x))typedef pair<int, int> pii;typedef pair<long long, long long> pll;typedef vector<int> vi;typedef vector<long long> vll;inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}int a[200005];int main(){//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);//ios::sync_with_stdio(0);//cin.tie(0);int n = read();rep(i,1,n) a[i] = read();int num = 0;for(int i=1,j=n;i<=j;i++,j--) { num++; int ta = a[i], tb = a[j]; if(num%2==1)a[i] = tb, a[j] = ta; }for(int i=1;i<=n;i++) { printf("%d",a[i]); if(i!=n)printf(" "); }return 0;}
0 0
- CF764 B. Timofey and cubes(水题)
- B - Timofey and cubes
- B. Timofey and cubes
- Timofey and cubes (水题)
- Codeforces Round #395 (Div. 2) B. Timofey and cubes(水题)
- 【codeforces 764B】Timofey and cubes
- 【codeforces 764B】Timofey and cubes 题解
- Codeforces 764B-Timofey and cubes
- CodeForces - 764B Timofey and cubes
- CodeForces 764B Timofey and cubes
- Codeforces Round #395(Div. 2)B. Timofey and cubes【模拟】
- CF764 C. Timofey and a tree(dfs序+线段树)
- 【Codeforces Round #395 (Div. 2)】Codeforces 764B Timofey and cubes
- Codeforces Round #395 (Div. 2)Timofey and cubes
- Codeforces 763B-Timofey and rectangles
- Codeforces 763B Timofey and rectangles(四色定理)(思维)
- B. Timofey and rectangles(四色定理,坐标奇偶错位)
- CF764 A. Taymyr is calling you(水题)
- Linux架构之HA配置
- [LeetCode]476.Number Complement
- springmvc也要扫描的原理
- poj 1925 Spiderman
- Oracle的安装与卸载
- CF764 B. Timofey and cubes(水题)
- 倒计时
- 各个数据库取前10行记录
- 年初日常~哈哈
- test
- 13.Handler中postdelay实现定时器功能
- uva 662 Fast Food
- 给Ubuntu 16.04更换更新源
- git添加文件到版本库的步骤