社区讨论
异或橙子38求条
题目总版参与者 2已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mhjultv8
- 此快照首次捕获于
- 2025/11/04 08:46 4 个月前
- 此快照最后确认于
- 2025/11/04 08:46 4 个月前
rt,评测记录(以整行为单位):
红
绿
红
绿
红
所以,求条。
CPP#include <bits/stdc++.h>
using namespace std;
int tji[114514], tou[114514], n, a[114514];
int lowbit (int x)
{
return x & -x;
}
void cmppji (int x, int y)
{
for (int i = x; i <= n; i += lowbit (i)) tji[i] ^= y;
}
int cmpppji (int x, int y)
{
int ans = 0;
for (int i = x - 1; i >= 1; i -= lowbit (i)) ans ^= tji[i];
for (int i = y; i >= 1; i -= lowbit (i)) ans ^= tji[i];
return ans;
}
void cmppou (int x, int y)
{
for (int i = x; i <= n; i += lowbit (i)) tou[i] ^= y;
}
int cmpppou (int x, int y)
{
int ans = 0;
for (int i = x - 1; i >= 1; i -= lowbit (i)) ans ^= tou[i];
for (int i = y; i >= 1; i -= lowbit (i)) ans ^= tou[i];
return ans;
}
int main()
{
int q;
cin >> n >> q;
for (int i = 1; i<= n; i ++)
{
cin >> a[i];
int x = a[i];
if (i & 1) cmppji (i, x);
else cmppou (i, x);
}
for (int i = 1; i<= q; i ++){
int x, y, z;
cin >> x >> y >> z;
if (x == 1)
{
if (y & 1)cmppji (z, a[y] ^ z);
else cmppou (z, a[y] ^ z);
a[y] = z;
}
else{
if ((y + z) & 1) cout << "0\n";
else
{
if (y & 1) cout << cmpppji(y, z);
else cout << cmpppou (y, z);
cout << endl;
}
}
}
return 0;
}
额外问一句,请问灌水没了,我要是有非洛谷上的问题比如生活问题那么该上哪里问呢??
逆天验证码 88wa
回复
共 5 条回复,欢迎继续交流。
正在加载回复...