Submission #3765999


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001;
const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii a(n);
  rep(i, 0, n) cin >> a[i];
  deque<int> b;
  rep(i, 0, n) {
    if (n % 2) {
      if (i % 2) b.push_back(a[i]);
      else b.push_front(a[i]);
    } else {
      if (i % 2) b.push_front(a[i]);
      else b.push_back(a[i]);
    }
  }
  rep(i, 0, n) { 
    cout << b[i] << (i != n-1 ? " " : "\n");
  }
  return 0;
}

Submission Info

Submission Time
Task C - pushpush
User kage
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1843 Byte
Status AC
Exec Time 40 ms
Memory 3840 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 12
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All even_0.txt, even_1.txt, even_2.txt, even_3.txt, odd_0.txt, odd_1.txt, odd_2.txt, odd_3.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
even_0.txt AC 39 ms 3840 KB
even_1.txt AC 39 ms 3840 KB
even_2.txt AC 39 ms 3840 KB
even_3.txt AC 39 ms 3840 KB
odd_0.txt AC 40 ms 3840 KB
odd_1.txt AC 40 ms 3840 KB
odd_2.txt AC 39 ms 3840 KB
odd_3.txt AC 39 ms 3840 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
sample4.txt AC 1 ms 256 KB