답안 #577124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577124 2022-06-14T06:54:44 Z dozer XORanges (eJOI19_xoranges) C++14
100 / 100
163 ms 16148 KB
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
#define L(node) node * 2
#define R(node) node * 2 + 1
#define int long long

int arr[N], tree[2][4 * N];

void update(int node, int l, int r, int sl, int x, int par)
{
	if (l > r || l > sl || r < sl) return;
	if (l == r)
	{
		if (l == sl) tree[par][node] = x;
		return;
	}
	int mid = (l + r) / 2;
	update(L(node), l, mid, sl, x, par);
	update(R(node), mid + 1, r, sl, x, par);
	tree[par][node] = tree[par][L(node)] ^ tree[par][R(node)];
}


int find(int node, int l, int r, int sl, int sr, int par)
{
	if (l > r || l > sr || r < sl) return 0;
	if (l >= sl && r <= sr) return tree[par][node];
	int mid = (l + r) / 2;
	return find(L(node), l, mid, sl, sr, par) ^ find(R(node), mid + 1, r, sl, sr, par);
}


int32_t main()
{
	//fileio();
	fastio();

	int n, q;
	cin>>n>>q;
	for (int i = 1; i <= n; i++)
	{
		cin>>arr[i];
		update(1, 1, n, i, arr[i], i % 2);
	}

	while(q--)
	{
		int type;
		cin>>type;
		if (type == 1)
		{
			int i, x;
			cin>>i>>x;
			arr[i] = x;
			update(1, 1, n, i, x, i % 2);
		}
		else
		{
			int l, r;
			cin>>l>>r;
			if ((r - l + 1) % 2 == 0) cout<<0<<endl;
			else cout<<find(1, 1, n, l, r, l % 2)<<endl;
		}
	}

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 4 ms 676 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 16148 KB Output is correct
2 Correct 147 ms 16076 KB Output is correct
3 Correct 154 ms 16116 KB Output is correct
4 Correct 141 ms 15752 KB Output is correct
5 Correct 131 ms 15716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 4 ms 676 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 4 ms 724 KB Output is correct
15 Correct 153 ms 16148 KB Output is correct
16 Correct 147 ms 16076 KB Output is correct
17 Correct 154 ms 16116 KB Output is correct
18 Correct 141 ms 15752 KB Output is correct
19 Correct 131 ms 15716 KB Output is correct
20 Correct 163 ms 15844 KB Output is correct
21 Correct 159 ms 15764 KB Output is correct
22 Correct 150 ms 15820 KB Output is correct
23 Correct 138 ms 15720 KB Output is correct
24 Correct 137 ms 15820 KB Output is correct