Submission #419989

# Submission time Handle Problem Language Result Execution time Memory
419989 2021-06-07T21:05:06 Z faruk XORanges (eJOI19_xoranges) C++17
18 / 100
5 ms 6732 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;
}

int niz[(int)1e5];
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, 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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 300 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 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 6732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -