Submission #577123

# Submission time Handle Problem Language Result Execution time Memory
577123 2022-06-14T06:52:21 Z dozer XORanges (eJOI19_xoranges) C++14
0 / 100
4 ms 596 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";
}

Compilation message

xoranges.cpp: In function 'int32_t main()':
xoranges.cpp:5:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:44:2: note: in expansion of macro 'fileio'
   44 |  fileio();
      |  ^~~~~~
xoranges.cpp:5:59: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:44:2: note: in expansion of macro 'fileio'
   44 |  fileio();
      |  ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -