Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <bits/stdc++.h>
- #include <string>
- #include <stack>
- #include <queue>
- #include <cstdio>
- #include <cmath>
- #include <iostream>
- #define vpii vector< pair<int,int> >
- #define vi vector<int>
- #define for0(i,a) for(int i=0;i<a;i++)
- #define pii pair <int,int>
- #define pll pair <long long,long long>
- #define sc scanf
- #define pf printf
- #define Pi 2*acos(0.0)
- #define ms(a,b) memset(a, b, sizeof(a))
- #define pb(a) push_back(a)
- #define MP make_pair
- #define db double
- #define ll long long
- #define ull unsigned long long
- #define f first
- #define s second
- #define sqr(x) (x)*(x)
- #define VI vector <int>
- #define DBG pf("Hi\n")
- #define MOD 1000000007
- #define SZ(a) (int)a.size()
- #define sf(a) scanf("%d",&a)
- #define sfl(a) scanf("%lld",&a)
- #define sff(a,b) scanf("%d %d",&a,&b)
- #define sffl(a,b) scanf("%lld %lld",&a,&b)
- #define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
- #define sfffl(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
- #define loop(i,n) for(int i=0;i<n;i++)
- #define loop1(i,n) for(int i=1;i<=n;i++)
- #define REP(i,a,b) for(int i=a;i<b;i++)
- #define RREP(i,a,b) for(int i=a;i>=b;i--)
- #define intlim 2147483648
- #define ull unsigned long long
- #define gcd(a, b) __gcd(a, b)
- #define lcm(a, b) ((a)*((b)/gcd(a,b)))
- #define mk(x1,y1) make_pair(x1, y1)
- #define maxl 10000
- #define psz 20
- #define Fin freopen("input.txt","r",stdin)
- #define Fout freopen("output.txt","w",stdout)
- /*----------------------Graph Moves----------------*/
- const int fx[]={+1,-1,+0,+0};
- const int fy[]={+0,+0,+1,-1};
- //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
- //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
- //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
- //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
- /*------------------------------------------------*/
- /*-----------------------Bitmask------------------*/
- //int Set(int N,int pos){return N=N | (1<<pos);}
- //int reset(int N,int pos){return N= N & ~(1<<pos);}
- //bool check(int N,int pos){return (bool)(N & (1<<pos));}
- //freopen("in.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- //ios_base::sync_with_stdio(false);
- //cin.tie(NULL);
- using namespace std;
- int main(){
- //Fin;
- // Fout;
- int t, cas = 1;
- scanf("%d",&t);
- while(t--){
- //cout << "R " << t <<endl;
- int n;
- scanf("%d",&n);
- // cout<<"E "<< n << endl;
- ll a[n + 3], a1[n + 3];
- for(int i = 0; i < n; i++){
- scanf("%lld",&a[i]);
- //cout<<"E "<< a[i] << endl;
- a1[i] = a[i];
- }
- for(int i = 1; i < n; i++){
- a[i] = a[i] ^ a[i - 1];
- }
- int q;
- printf("Case %d:\n", cas++);
- scanf("%d",&q);
- while(q--){
- int l, r;
- scanf("%d%d",&l, &r);
- if( l == r){
- printf("%lld\n", a1[l]);
- continue;
- }
- int range = ( r - l) + 1;
- ll now = 0;
- if(range % 2 == 0){
- if(l > 0){
- now = a[r] ^ a[l - 1];
- }
- else now = a[r];
- printf("%lld\n", now);
- }
- else{
- now = a1[l] ^ a1[r];
- printf("%lld\n", now);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement