Submission #419992

# Submission time Handle Problem Language Result Execution time Memory
419992 2021-06-07T21:07:24 Z faruk XORanges (eJOI19_xoranges) C++17
100 / 100
622 ms 10768 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <queue>
#include <math.h>
#define ll long long
#define pii pair<int, int>

using namespace std;

int n, q;

void update(vector<int> &tree, int index, int value)
{
	int oldValue = tree[index];

	for (; index > 0; index /= 2)
		tree[index] ^= oldValue, tree[index] ^= value;
}

int query(vector<int>& tree, int l, int r)
{
	int out = 0;
	r++;
	
	for (l += n, r += n; l < r; l /= 2, r /= 2)
	{
		if (l & 1)
			out ^= tree[l++];
		if (r & 1)
			out ^= tree[--r];
	}
	return out;
}

ll niz[(int)4e5];
vector<int> parno;
vector<int> neparno;
int main()
{
	cin >> n >> q;
	parno.resize(2 * n + 1);
	neparno.resize(2 * n + 1);
	for (int i = n; i < 2 * n; i++)
	{
		cin >> niz[i];
		if ((i - n) % 2 == 0)
			update(parno, i, niz[i]);
		else
			update(neparno, i, niz[i]);
	}

	for (int i = 0; i < q; i++)
	{
		int type, r, l;
		cin >> type >> l >> r;
		r--, l--;

		if (type == 1)
		{
			r++;
			if (l % 2 == 0)
				update(parno, l + n, r);
			else
				update(neparno, l + n, r);
		}
		else
		{
			if ((r - l + 1) % 2 == 0)
				cout << 0 << endl;
			else
			{
				if (l % 2 == 0)
					cout << query(parno, l, r) << endl;
				else
					cout << query(neparno, l, r) << endl;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 12 ms 536 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 14 ms 528 KB Output is correct
14 Correct 16 ms 540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 618 ms 6140 KB Output is correct
2 Correct 616 ms 6220 KB Output is correct
3 Correct 622 ms 6324 KB Output is correct
4 Correct 613 ms 6140 KB Output is correct
5 Correct 613 ms 6084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 12 ms 536 KB Output is correct
12 Correct 11 ms 460 KB Output is correct
13 Correct 14 ms 528 KB Output is correct
14 Correct 16 ms 540 KB Output is correct
15 Correct 618 ms 6140 KB Output is correct
16 Correct 616 ms 6220 KB Output is correct
17 Correct 622 ms 6324 KB Output is correct
18 Correct 613 ms 6140 KB Output is correct
19 Correct 613 ms 6084 KB Output is correct
20 Correct 490 ms 10768 KB Output is correct
21 Correct 472 ms 10684 KB Output is correct
22 Correct 476 ms 10736 KB Output is correct
23 Correct 596 ms 10584 KB Output is correct
24 Correct 575 ms 10652 KB Output is correct