alexjercan/bugnet huggingface dataset:
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using LL = long long;
const int MAX_N = 200 + 10;

int n;
LL a[MAX_N];
char s[MAX_N];
struct LB {
  LL a[61];

  LL add(LL x) {
    for (int i = 60; i >= 0; --i)
      if (x >> i & 1) {
        if (a[i] == 0) {
          a[i] = x;
          break;
        }
        x ^= a[i];
      }
    return x;
  }
} lb;

int main() {
  int T;
  for (scanf("%d", &T); T; --T) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
      scanf("%lld", a + i);
    scanf("%s", s + 1);
    for (int i = 0; i <= 60; ++i)
      lb.a[i] = 0;
    int ans = 0;
    for (int i = n; i >= 1; --i)
      if (s[i] == '0') {
        lb.add(a[i]);
      } else {
        LL d = lb.add(a[i]);
        ans |= d != 0;
      }
    printf("%d\\n", ans);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define Maxn 207
using namespace std;
int T, n;
long long a[Maxn];
int op[Maxn];
long long r[62], w;
void add(long long x) {
  for (int i = 60; i >= 0; i--)
    if (x & (1LL << i)) {
      if (r[i])
        x ^= r[i];
      else {
        r[i] = x;
        w ^= (1LL << i);
        break;
      }
    }
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++) {
    char ch = getchar();
    while (ch != '0' && ch != '1')
      ch = getchar();
    if (ch == '0')
      op[i] = 0;
    else
      op[i] = 1;
  }
  memset(r, 0, sizeof(r));
  w = 0LL;
  while (n > 0) {
    if (op[n] == 1) {
      printf("%d\\n", 1);
      return;
    }
    int id = n;
    while (id > 0 && op[id] == 0)
      --id;
    ++id;
    for (int i = id; i <= n; i++)
      add(a[i]);
    int m = 0;
    for (int i = 1; i <= n; i++)
      if ((a[i] & w) != a[i]) {
        ++m;
        a[m] = a[i];
        op[m] = op[i];
      }
    n = m;
  }
  printf("%d\\n", 0);
}
int main() {
  scanf("%d", &T);
  while (T--)
    solve();
  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define F first
#define S second
#define int long long
#define mpr make_pair
typedef long long ll;

const int maxn = 210;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 10;

bool good[maxn];
bool is(vector<int> s, int x) {
  memset(good, 0, sizeof good);
  ll res = 0;
  for (int i = 61; i >= 0; i--) {
    int id = -1;
    for (int j = 0; j < s.size(); j++)
      if ((s[j] & (1ll << i)) && !good[j])
        id = j;

    bool XX = ((1ll << i) & x);
    bool YY = ((1ll << i) & res);
    if ((XX ^ YY) && id != -1)
      (res ^= s[id]);

    good[id] = 1;
    for (int j = 0; j < s.size(); j++)
      if (id != j && ((1ll << i) & s[j]))
        s[j] ^= s[id];
  }
  if (res == x)
    return 1;
  else
    return 0;
}

int a[maxn];
signed main() {
  // ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  //  cout<< is({7,6,5}, 3) <<" ";
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    string s;
    cin >> s;

    vector<int> ve;
    bool ans = 0;
    //  cout<<"\\n";
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == '0')
        ve.push_back(a[i]);
      else if (!is(ve, a[i])) {
        //       cout<< i <<" ";
        ans = 1;
        break;
      }
    }
    cout << ans << "\\n";
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define F first
#define S second
#define int long long
#define mpr make_pair
typedef long long ll;

const int maxn = 210;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 10;

bool is(vector<int> s, int x) {
  bool good[64];
  memset(good, 0, sizeof good);
  for (int i = 60; i >= 0; i--)
    if ((1ll << i) & x) {
      int id = -1;
      for (int j = 0; j < s.size(); j++)
        if (s[j] & (1ll << i))
          if (!good[j])
            id = j;

      if (id == -1)
        return 0;

      good[id] = 1;
      for (int j = 0; j < s.size(); j++)
        if (id != j)
          s[j] ^= s[id];
    }
  return 1;
}

int a[maxn];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
      cin >> a[i];
    string s;
    cin >> s;
    vector<int> ve;
    bool ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == '0')
        ve.push_back(a[i]);
      else if (!is(ve, a[i]))
        ans = 1;
    }
    cout << ans << "\\n";
  }
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF * INF * 10;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    string s;
    cin >> s;
    bool x = false;

    vector<ll> bits(62);
    for (int i = n - 1; i >= 0; --i) {
      if (s[i] == '0') {
        for (int j = 61; j >= 0; --j) {
          if ((a[i] >> j) & 1) {
            a[i] ^= bits[j];
          }
        }
        int num = 63 - __builtin_clzll(a[i]);
        if (num < 0)
          continue;
        rep(j, 62) {
          if (((bits[j] >> num) & 1) or j == num) {
            bits[j] ^= a[i];
          }
        }
      } else {
        for (int j = 61; j >= 0; --j) {
          if ((a[i] >> j) & 1) {
            a[i] ^= bits[j];
          }
        }
        if (a[i]) {
          cout << 1 << '\\n';
          x = true;
        }
      }
      if (x)
        break;
    }
    if (!x)
      cout << 0 << '\\n';
  }
}

Error: TLE

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF * INF * 10;

int main() {
  int t;
  cin >> t;
  rep(i, t) {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) { cin >> a[i]; }
    string s;
    cin >> s;

    if (s[n - 1] - '0') {
      cout << 1 << endl;
      continue;
    }

    reverse(all(s));
    reverse(all(a));
    set<ll> se;
    se.insert(0);
    rep(i, n) {
      if (s[i] == '0') {
        vi x;
        for (ll xx : se) {
          x.push_back(xx ^ a[i]);
        }
        rep(i, x.size()) { se.insert(x[i]); }
      } else {
        vi x;
        for (ll xx : se) {
          if (se.find(xx ^ a[i]) == se.end()) {
            x.push_back(xx);
          }
        }
        rep(i, x.size()) { se.erase(x[i]); }
      }
    }
    if (se.find(0) != se.end()) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

int main() {
  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    vec a(n);
    for (ll i = 0; i < n; i++)
      cin >> a[i];
    string s;
    cin >> s;
    vec al;
    ll f = 0;
    for (ll i = n - 1; i >= 0; i--) {
      for (ll t : al) {
        a[i] = min(a[i], a[i] ^ t);
      }
      al.push_back(a[i]);
      if (a[i] && s[i] == '1') {
        f = 1;
      }
    }
    cout << f << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

int main() {
  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    vec a(n);
    for (ll i = 0; i < n; i++)
      cin >> a[i];
    string s;
    cin >> s;
    set<ll> al;
    al.insert(0);
    ll f = 0;
    for (ll i = n - 1; i >= 0; i--) {
      if (s[i] == '0') {
        set<ll> tmp;
        for (ll t : al) {
          tmp.insert(t ^ a[i]);
        }
        for (ll t : tmp) {
          al.insert(t);
        }
      } else {
        if (!al.count(a[i])) {
          f = 1;
        }
      }
    }
    cout << f << endl;
  }
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;

int n;
ll a[205];
string s;

void meow() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> s;
  vector<ll> t;
  for (int i = n - 1; i >= 0; i--) {
    ll c = a[i];
    for (ll &x : t) {
      c = min(c, c ^ x);
    }
    if (c) {
      if (s[i] == '1') {
        cout << "1\\n";
        return;
      }
      t.push_back(c);
    }
  }
  cout << "0\\n";
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int T;
  cin >> T;
  while (T--) {
    meow();
  }

  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;

int n;
ll a[205];
char s[205];
set<ll> dp[205];

void meow() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> s;
  dp[n].clear();
  dp[n].insert(0);
  for (int i = n; i--;) {
    dp[i].clear();
    if (s[i] == '0') {
      for (const ll &x : dp[i + 1]) {
        dp[i].insert(x);
        dp[i].insert(x ^ a[i]);
      }
    } else if (dp[i + 1].find(a[i]) != dp[i + 1].end()) {
      dp[i] = dp[i + 1];
    }
  }
  cout << (dp[0].find(0) == dp[0].end()) << endl;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int T;
  cin >> T;
  while (T--) {
    meow();
  }

  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010, M = 64;
ll a[N];
int n;
char s[N];
ll b[N];

ll insert(ll x) {
  for (int i = 60; ~i; i--)
    if (1 & (x >> i)) {
      if (!b[i]) {
        b[i] = x;
        break;
      } else
        x ^= b[i];
    }
  return x;
}

void Main() {
  for (int i = 0; i < M; i++)
    b[i] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  scanf("%s", s + 1);
  bool Ans = 0;
  for (int i = n; i; i--) {
    if (s[i] == '0') {
      insert(a[i]);
    } else {
      ll d = insert(a[i]);
      // cerr << d << "??" << endl;
      Ans |= d != 0;
    }
  }
  printf("%d\\n", (int)Ans);
}

int main() {
  int T;
  cin >> T;
  while (T--)
    Main();
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char q[10000000];
char p[10000000];
ll k[300];
bool add(ll x) {
  for (ll i = 63; i >= 0; i--) {
    if ((x >> i) & 1) {
      if (!k[i]) {
        k[i] = x;
        return 1;
      } else
        x = x ^ k[i];
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  ll a, b, c, d, e, f, g, h, i, j, t;
  cin >> t;
  while (t--) {
    cin >> b;
    for (ll i = 0; i < b; i++)
      cin >> p[i];
    cin >> q;
    ll flag = 0;
    for (ll i = b - 1; i >= 0; i--) {
      if (add(p[i]) && q[i] == '1') {
        flag = 1;
        break;
      }
    }
    cout << flag << endl;
  }
  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
// i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
  i64 t;
  cin >> t;

  for (int ti = 0; ti < t; ++ti) {
    i64 n;
    cin >> n;
    std::vector<i64> a(n);
    std::vector<i64> xo = {0};
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    string s;
    cin >> s;

    bool res{true};

    for (int i = n - 1; i >= 0; --i) {
      i64 num = a[i];
      for (i64 v : xo)
        num = min(num, num ^ v);
      if (num) {
        if (s[i] == '0') {
          xo.push_back(num);
        } else {
          res = false;
          break;
        }
      }
    }
    cout << (res ? '0' : '1') << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
// i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
  i64 t;
  cin >> t;

  for (int ti = 0; ti < t; ++ti) {
    i64 n;
    cin >> n;
    std::vector<i64> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    string s;
    cin >> s;
    std::unordered_set<i64> w;
    w.insert(0);

    for (int i = n - 1; i >= 0; --i) {
      std::unordered_set<i64> w_new = w;
      if (s[i] == '0') {
        for (auto v : w)
          w_new.insert(a[i] ^ v);
      } else {
        auto it = w.find(a[i]);
        if (it == w.end()) {
          w_new = std::unordered_set<i64>();
        }
      }
      w = std::move(w_new);
    }
    cout << (w.empty() ? '1' : '0') << endl;
  }

  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int T;
  cin >> T;
  vll ans;
  rep(j, T) {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    string s;
    cin >> s;
    vll b;
    bool ok = true;
    per(i, n) {
      ll v = a[i];
      for (auto x : b)
        v = min(v, v ^ x);
      if (v) {
        if (s[i] == '1')
          ok = false;
        b.push_back(v);
      }
    }
    if (ok)
      ans.push_back(0);
    else
      ans.push_back(1);
  }
  rep(j, T) cout << ans[j] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int T;
  cin >> T;
  vll ans;
  rep(j, T) {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    string s;
    cin >> s;
    map<ll, ll> mp;
    bool ok = true;
    per(i, n) {
      if (s[i] == '0') {
        for (auto p : mp)
          mp[p.first ^ a[i]]++;
        mp[a[i]]++;
      }
      if (s[i] == '1')
        if (mp[a[i]] == 0)
          ok = false;
    }
    if (ok)
      ans.push_back(0);
    else
      ans.push_back(1);
  }
  rep(j, T) cout << ans[j] << endl;
  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

// agc045_a.cpp
// Sun Jul  5 18:44:30 2020

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main() {
  int t;
  cin >> t;

  rep(i, t) {
    int n;
    cin >> n;
    ll a[n];
    rep(j, n) cin >> a[j];
    string s;
    cin >> s;

    vector<ll> xors;
    int ans = 0;
    for (int j = n - 1; j >= 0; j--) {
      ll x = a[j];
      rep(k, xors.size()) { x = min(x, x ^ xors[k]); }
      if (x) {
        if (s[j] == '0') {
          xors.push_back(x);
        } else {
          ans = 1;
          break;
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

// agc045_a.cpp
// Sun Jul  5 18:44:30 2020

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main() {
  int t;
  cin >> t;

  rep(i, t) {
    int n;
    cin >> n;
    ll a[n];
    rep(j, n) cin >> a[j];
    string s;
    cin >> s;

    vector<ll> xors;
    xors.push_back(0);
    int flag = 0;
    for (int j = n - 1; j >= 0; j--) {
      int len = xors.size();
      if (s[j] == '0') {
        rep(k, len) { xors.push_back(xors[k] ^ a[j]); }
      } else {
        int tmpflag = 1;
        rep(k, len) {
          if (a[j] == xors[k]) {
            tmpflag = 0;
          }
        }
        if (tmpflag) {
          flag = 1;
          break;
        }
      }
    }
    if (flag) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}
Problem p02651 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 271, B = 61;
int t, n, flg;
ll x, k, a[MAXN], b[MAXN];
char s[MAXN];
bool ins(ll x) {
  for (int i = B; i >= 0; i--) {
    if ((x & (1ll << i))) {
      if (b[i]) {
        x ^= b[i];
      } else {
        b[i] = x;
        break;
      }
    }
  }
  if (x) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  scanf("%d", &t);
  for (int ii = 1; ii <= t; ii++) {
    memset(b, 0, sizeof(b));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    scanf("%s", s + 1);
    int flg = 0;
    for (int i = n; i >= 1; i--) {
      if (s[i] == '0') {
        ins(a[i]);
      } else {
        if (ins(a[i])) {
          flg = 1;
          break;
        }
      }
    }
    printf("%d\\n", flg);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 71, B = 61;
int t, n, flg;
ll x, k, a[MAXN], b[MAXN];
char s[MAXN];
bool ins(ll x) {
  for (int i = B; i >= 0; i--) {
    if ((x & (1ll << i))) {
      if (b[i]) {
        x ^= b[i];
      } else {
        b[i] = x;
        break;
      }
    }
  }
  if (x) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  scanf("%d", &t);
  for (int ii = 1; ii <= t; ii++) {
    memset(b, 0, sizeof(b));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    scanf("%s", s + 1);
    int flg = 0;
    for (int i = n; i >= 1; i--) {
      if (s[i] == '0') {
        ins(a[i]);
      } else {
        if (ins(a[i])) {
          flg = 1;
          break;
        }
      }
    }
    printf("%d\\n", flg);
  }
  return 0;
}
Problem p02651 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
using namespace std;

void solve() {
  int n;
  cin >> n;
  ll a[n], base[65];
  memset(base, 0, sizeof base);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  string s;
  cin >> s;
  for (int i = n - 1; ~i; --i) {
    bool contains = true;
    for (int bit = 0; bit < 61; ++bit) {
      if (a[i] >> bit & 1) {
        if (!base[bit]) {
          contains = false;
          base[bit] = a[i];
          break;
        }
        a[i] ^= base[bit];
      }
    }
    if (!contains) {
      if (s[i] == '1') {
        cout << "1\\n";
        return;
      }
    }
  }
  cout << "0\\n";
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#pragma GCC diagnostic warning "-std=c++11"
using namespace std;
const int N = 2e5 + 10;
void solve() {
  int n;
  cin >> n;
  ll a[n + 1];
  set<ll> s0, s1, newS0, newS1;
  vector<ll> g0, g1;
  s0.insert(0);
  s1.insert(0);
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0')
      g0.push_back(a[i + 1]);
    if (s[i] == '1')
      g1.push_back(a[i + 1]);
  }
  for (int i = 0; i < g0.size(); ++i) {
    for (auto it = s0.begin(); it != s0.end(); ++it) {
      newS0.insert(*it ^ g0[i]);
    }
    for (auto it = newS0.begin(); it != newS0.end(); ++it)
      s0.insert(*it);
    newS0.clear();
  }
  for (int i = 0; i < g1.size(); ++i) {
    for (auto it = s1.begin(); it != s1.end(); ++it) {
      newS1.insert(*it ^ g1[i]);
    }
    for (auto it = newS1.begin(); it != newS1.end(); ++it)
      s1.insert(*it);
    newS1.clear();
  }
  for (auto it = s1.begin(); it != s1.end(); ++it) {
    if (s0.find(*it) == s0.end()) {
      cout << "1\\n";
      return;
    }
  }
  cout << "0\\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
Problem p02651 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010, M = 64;

ll a[N];
int n;
char s[N];

ll b[N];

ll insert(ll x) {
  for (int i = 60; ~i; i--)
    if (1 & (x >> i)) {
      if (!b[i]) {
        b[i] = x;
        break;
      } else
        x ^= b[i];
    }
  return x;
}

void Main() {
  for (int i = 0; i < M; i++)
    b[i] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  scanf("%s", s + 1);
  bool Ans = 0;
  for (int i = n; i; i--) {
    if (s[i] == '0') {
      insert(a[i]);
    } else {
      ll d = insert(a[i]);
      // cerr << d << "??" << endl;
      Ans |= d != 0;
    }
  }
  printf("%d\\n", (int)Ans);
}

int main() {
  int T;
  cin >> T;
  while (T--)
    Main();
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 110, M = 64;

ll a[N];
int n;
char s[N];

ll b[N];

ll insert(ll x) {
  for (int i = 60; ~i; i--)
    if (1 & (x >> i)) {
      if (!b[i]) {
        b[i] = x;
        break;
      } else
        x ^= b[i];
    }
  return x;
}

void Main() {
  for (int i = 0; i < M; i++)
    b[i] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  scanf("%s", s + 1);
  bool Ans = 0;
  for (int i = n; i; i--) {
    if (s[i] == '0') {
      insert(a[i]);
    } else {
      ll d = insert(a[i]);
      // cerr << d << "??" << endl;
      Ans |= d != 0;
    }
  }
  printf("%d\\n", (int)Ans);
}

int main() {
  int T;
  cin >> T;
  while (T--)
    Main();
}