이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0);
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
const int sq = 450;
int sq_xor1[sq], sq_xor2[sq];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, q;
cin >> n >> q;
int a[n];
int a1[(n + 1) / 2], a2[n / 2];
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i % 2 == 0) {
a1[i / 2] = a[i];
}
else {
a2[i / 2] = a[i];
}
}
for (int i = 0; i < (n + 1) / 2; i++) {
sq_xor1[i / sq] ^= a1[i];
}
for (int i = 0; i < n / 2; i++) {
sq_xor2[i / sq] ^= a2[i];
}
for (int I = 0; I < q; I++) {
int x;
cin >> x;
if (x == 2) {
int l, r;
cin >> l >> r;
l -= 1; r -= 1;
int le = r - l + 1;
if (le % 2 == 0) {
cout << 0 << endl;
}
else {
int output = 0;
if (l % 2 == 0) {
l /= 2; r /= 2;
if (le <= 3 * sq) {
for (int i = l; i <= r; i++) {
output ^= a1[i];
}
}
else {
int j1 = (l / sq) * sq + sq, j2 = (r / sq) * sq;
for (int i = l; i < j1; i++) {
output ^= a1[i];
}
for (int i = j1; i < j2; i += sq) {
output ^= sq_xor1[i / sq];
}
for (int i = j2; i <= r; i++) {
output ^= a1[i];
}
}
}
else {
l /= 2; r /= 2;
if (le <= 3 * sq) {
for (int i = l; i <= r; i++) {
output ^= a2[i];
}
}
else {
int j1 = (l / sq) * sq + sq, j2 = (r / sq) * sq;
for (int i = l; i < j1; i++) {
output ^= a2[i];
}
for (int i = j1; i < j2; i += sq) {
output ^= sq_xor2[i / sq];
}
for (int i = j2; i <= r; i++) {
output ^= a2[i];
}
}
}
cout << output << endl;
}
}
else {
int i, v;
cin >> i >> v;
i -= 1;
if (i % 2 == 0) {
i /= 2;
sq_xor1[i / sq] ^= a1[i];
a1[i] = v;
sq_xor1[i / sq] ^= a1[i];
}
else {
i /= 2;
sq_xor2[i / sq] ^= a2[i];
a2[i] = v;
sq_xor2[i / sq] ^= a2[i];
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |