题目链接:
zxa and xor
Time Limit: 16000/8000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
zxa thought only doing this was too boring, hence a function funct(x,y) defined by him, in which ax would be changed into y irrevocably and then compute ⊗1≤i<j≤n(ai+aj) as return value.
zxa is interested to know, assuming that he called such function m times for this sequence, then what is the return value for each calling, can you help him?
tips:⊗1≤i<j≤n(ai+aj) means that (a1+a2)⊗(a1+a3)⊗⋯⊗(a1+an)⊗(a2+a3)⊗(a2+a4)⊗⋯⊗(a2+an)⊗⋯⊗(an−1+an).
For each test case:
The first line contains two positive integers n and m.
The second line contains n non-negative integers, represent a1,a2,⋯,an.
The next m lines, the i-th line contains two non-negative integers x and y, represent the i-th called function is funct(x,y).
There is a blank between each integer with no other extra space in one line.
1≤T≤1000,2≤n≤2⋅10^4,1≤m≤2⋅10^4,0≤ai,y≤10^9,1≤x≤n,1≤∑n,∑m≤10^5
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int N=2e4+;
int n,m;
int a[N],ans;
int get_ans()
{
ans=;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
int sum=a[i]+a[j];
ans^=sum;
}
}
}
int fun(int fx,int fy)
{
for(int i=;i<=n;i++)
{
if(i!=fx) ans^=(a[fx]+a[i])^(fy+a[i]);
}
a[fx]=fy;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
int x,y;
get_ans(); while(m--)
{
scanf("%d%d",&x,&y);
fun(x,y);
printf("%d\n",ans);
}
}
return ;
}