# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020806 | FIFI_cpp | XORanges (eJOI19_xoranges) | C++17 | 1101 ms | 2640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = int64_t;
#define pb push_back
#define all(a) a.begin(),a.end()
#define ppi pair<pair<int,int>,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define int int64_t
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("sleepy.in");
//ofstream fout ("sleepy.out");
/* /\_/\
* (= ._.)
* / > \>
*/
// encouraging cat
const int INF = 10000000000000000;
const int mod = 1000000007;
int32_t main() {
int n,q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0;i < n;i++)
cin >> a[i];
bool ok = true;
for (int i = 0;i < n;i++)
{
if (a[i] != i + 1)
ok = false;
}
assert(!ok);
while (q--)
{
int t;
cin >> t;
if (t == 1)
{
int i,v;
cin >> i >> v;
i--;
a[i] = v;
}
else
{
int l,r;
cin >> l >> r;
l--;
r--;
if ((l - r + 1) % 2 == 0)
{
cout << 0 << '\n';
continue;
}
else if (l - r + 1 == 1)
{
cout << a[l] << '\n';
continue;
}
else if (l - r + 1 == 2)
{
int cr = a[l];
cr ^= a[r];
cout << cr << '\n';
continue;
}
int res = 0;
for (int i = l;i <= r;i += 2)
{
res ^= a[i];
}
cout << res << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | 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... |