Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>>
#define vpii vector<pair<ll, ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

ll ceil1(ll n, ll m) {
  if (n % m == 0) {
    return n / m;
  }
  return n / m + 1;
}
vll factor(ll n) {
  vll ans;
  if (n == 2)
    ans.pb(2);
  else {
    for (ll i = 2; i * i <= n; i++) {
      if (n % i == 0 && n % i != i) {
        ans.pb(i);
        if (n / i != i)
          ans.pb(n / i);
      }
    }
    ans.pb(n);
  }
  return ans;
}
ll fact(ll n) {
  ll res = 1;
  for (ll i = 2; i <= n; i++)
    res = res * i;
  return res;
}

ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }

void dfs(vllv &v, ll k, vll &par, vll &dis, ll p) {
  par[k] = p;
  dis[k] = dis[p] + 1;
  for (ll i = 0; i < v[k].sz; i++) {
    if (v[k][i] != p) {
      dfs(v, v[k][i], par, dis, k);
    }
  }
}
bool sortbysec(const pair<string, int> &a, const pair<string, int> &b) {
  return (a.second < b.second);
}

ll pow2(ll n, ll k) {
  ll ans = 1;
  while (k > 0) {
    if (k % 2 == 1)
      ans = ans * n;
    n = n * n;
    k /= 2;
  }
  return ans;
}
bool prime(int n) {
  int i, j;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
bool bserch(vector<string> a, string s) {
  ll l = 0, r = a.sz - 1, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (a[mid] == s)
      return true;
    if (a[mid] < s) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return false;
}

bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

ll degit(ll n) {
  ll t = 0;
  while (n > 0) {
    t++;
    n /= 10;
  }
  return t;
}
void ff() { cout << "FastestFinger" << endl; }

void aa() { cout << "Ashishgup" << endl; }

void solve() {
  ll n, sum = 0;
  cin >> n;
  vll a(n + 1), cnt(n + 1);
  ll x = 0;
  for (ll i = 1; i <= n; i++)
    cin >> a[i], x = x ^ a[i];
  ;

  for (ll i = 1; i <= n; i++) {
    cnt[i] = x ^ a[i];
  }
  for (ll i = 1; i <= n; i++)
    cout << cnt[i] << " ";
}
int main() {
  fast;
  ll q;
  q = 1;
  // cin>>q;
  while (q--) {
    solve();
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>>
#define vpii vector<pair<ll, ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

ll ceil1(ll n, ll m) {
  if (n % m == 0) {
    return n / m;
  }
  return n / m + 1;
}
vll factor(ll n) {
  vll ans;
  if (n == 2)
    ans.pb(2);
  else {
    for (ll i = 2; i * i <= n; i++) {
      if (n % i == 0 && n % i != i) {
        ans.pb(i);
        if (n / i != i)
          ans.pb(n / i);
      }
    }
    ans.pb(n);
  }
  return ans;
}
ll fact(ll n) {
  ll res = 1;
  for (ll i = 2; i <= n; i++)
    res = res * i;
  return res;
}

ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }

void dfs(vllv &v, ll k, vll &par, vll &dis, ll p) {
  par[k] = p;
  dis[k] = dis[p] + 1;
  for (ll i = 0; i < v[k].sz; i++) {
    if (v[k][i] != p) {
      dfs(v, v[k][i], par, dis, k);
    }
  }
}
bool sortbysec(const pair<string, int> &a, const pair<string, int> &b) {
  return (a.second < b.second);
}

ll pow2(ll n, ll k) {
  ll ans = 1;
  while (k > 0) {
    if (k % 2 == 1)
      ans = ans * n;
    n = n * n;
    k /= 2;
  }
  return ans;
}
bool prime(int n) {
  int i, j;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
bool bserch(vector<string> a, string s) {
  ll l = 0, r = a.sz - 1, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (a[mid] == s)
      return true;
    if (a[mid] < s) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  return false;
}

bool sortcol(const vector<int> &v1, const vector<int> &v2) {
  return v1[0] < v2[0];
}

ll degit(ll n) {
  ll t = 0;
  while (n > 0) {
    t++;
    n /= 10;
  }
  return t;
}
void ff() { cout << "FastestFinger" << endl; }

void aa() { cout << "Ashishgup" << endl; }

void solve() {
  ll n, sum = 0;
  cin >> n;
  vll a(n + 1), cnt(n + 1);
  for (ll i = 1; i <= n; i++)
    cin >> a[i], sum += a[i], cnt[a[i]]++;

  for (ll i = 1; i <= n; i++) {
    cnt[i] = 0;
    for (ll j = 1; j <= n; j++) {
      if (i != j)
        cnt[i] = cnt[i] ^ a[j];
    }
  }
  for (ll i = 1; i <= n; i++)
    cout << cnt[i] << " ";
}
int main() {
  fast;
  ll q;
  q = 1;
  // cin>>q;
  while (q--) {
    solve();
  }
  return 0;
}