Problem p03675 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vi num(n);
  REP(i, n)
  cin >> num[i];
  vi ans;
  REP(i, n) {
    ans.push_back(num[i]);
    reverse(ans.begin(), ans.end());
  }
  REP(i, n) {
    cout << ans[i];
    if (i != n - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vi num(n);
  REP(i, n)
  cin >> num[i];
  vi ans(n);
  if (n % 2 == 0) {
    REP(i, n) {
      if (i % 2 == 0) {
        ans[n / 2 + (i / 2)] = num[i];
      } else {
        ans[n / 2 - 1 - (i / 2)] = num[i];
      }
    }
  } else {
    REP(i, n) {
      if (i % 2 == 0) {
        ans[n / 2 - (i / 2)] = num[i];
      } else {
        ans[n / 2 + 1 + (i / 2)] = num[i];
      }
    }
  }
  REP(i, n) {
    cout << ans[i];
    if (i != n - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}