이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// oranges.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
vector<int> odd;
vector<int> eve;
vector<int> val;
int n, q;
void fun() {
int xo = 0;
for (int i = 0; i < n; i += 2) {
xo = xo ^ val[i];
eve.push_back(xo);
}
xo = 0;
for (int i = 1; i < n; i += 2) {
xo = xo ^ val[i];
odd.push_back(xo);
}
}
int main()
{
cin >> n;
cin >> q;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
val.push_back(x);
}
fun();
for (int i = 0; i < q; i++) {
int a, b, c;
cin >> a;
cin >> b;
cin >> c;
if (a == 1) {
val[b - 1] = c;
fun();
}
else {
if ((b - c-1) % 2 == 0) {
cout << 0 << endl;
}
else {
if ((b - 1) % 2 == 0) {
int x = (odd[(b - 2) / 2])^(odd[(c-2) / 2]);
cout << x << endl;
}
else {
int x = eve[(b - 2) / 2] ^ eve[(c-2) / 2];
cout << x << endl;
}
}
}
}
}
# | 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... |