Untitled

 avatar
user_5668965
c_cpp
19 days ago
977 B
2
Indexable
Never
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n;
        cin >> n; 
        vector<int> a(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> a[i]; 
        }

        string s;
        cin >> s; 
        int q;
        cin >> q; 

        vector<int> ans(2, 0); 
        vector<int> pref(n + 1, 0); 
        for (int i = 1; i <= n; ++i) {
            ans[s[i - 1] - '0'] ^= a[i]; 
            pref[i] = pref[i - 1] ^ a[i]; 
        }

        int massxor = 0; 
        while (q--) {
            int tp;
            cin >> tp; 
            if (tp == 1) {
                int l, r;
                cin >> l >> r; 
                massxor ^= (pref[r] ^ pref[l - 1]); 
            } else {
                int g;
                cin >> g; 
                cout << (massxor ^ ans[g]) << endl; 
            }
        }
    }
    return 0;
}
Leave a Comment