Codeforces 1462A Favorite Sequence 2020-12-16 模拟 模拟 本文总阅读量次 题意 给一个数组$b$,形如$a_1,a_3,…,a_4,a_2$,要求还原出$a$数组。 分析 看$b$数组里奇数项是从左往右,偶数项是从右往左,维护一个左指针$l$,一个右指针$r$模拟即可。 12345678910111213141516171819202122232425262728293031323334353637383940414243#pragma GCC optimize(3, "Ofast", "inline")#include <bits/stdc++.h>#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);#define ll long long#define ull unsigned long long#define int ll#define ls st<<1#define rs st<<1|1#define pii pair<int,int>#define rep(z, x, y) for(int z=x;z<=y;++z)#define repd(z, x, y) for(int z=x;z>=y;--z)#define com bool operator<(const node &b)constusing namespace std;mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());const int maxn = (ll) 1e6 + 5;const int mod = 998244353;const int inf = 0x3f3f3f3f;int T = 1;int a[maxn];void solve() { int n; cin >> n; rep(i, 1, n)cin >> a[i]; int l = 1, r = n; rep(i, 1, n) { if (i & 1) cout << a[l++] << ' '; else cout << a[r--] << ' '; } cout << '\n';}signed main() { start; cin >> T; while (T--) solve(); return 0;} Codeforces 1462B Last Year's Substring AtCoder ABC183F Confluence