답안 #446724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
446724 2021-07-23T07:31:27 Z fuad27 XORanges (eJOI19_xoranges) C++14
38 / 100
666 ms 3936 KB
#include<bits/stdc++.h>
using namespace std;
#define pass true
int main () {
	int n, q;
	cin >> n >> q;
	vector<int> prefix(n+1, 0);
	vector<int> prefixOdd(n+1, 0);
	vector<int> v(n, 0);
	bool check = false;
	for(int i = 0;i<n;i++) {
		int p;
		cin >> p;
		prefix[i+1] = prefix[i] ^ p;
		if(i%2 == 0) {
			prefixOdd[i+1] = prefixOdd[i] ^ p;
		}
		else {
			prefixOdd[i+1] = prefixOdd[i];
		}
		v[i] = p;	
	}
	while(q--) {
		int k;
		cin >> k;
		if(k == 1) {
			check = true;
			int i, j;
			cin >> i >> j;
			v[i-1] = j;
		}
		else {
			int l, u;
			cin >> l >> u;
			if(!check) {
				if((u - l)%2 == 0) {
					if(l%2 == 1) {
						int ans = prefixOdd[u] ^ prefixOdd[l-1];
						cout<<(ans)<<endl;
					}
					else {
						int ans = prefix[u] ^ prefixOdd[u] ^ prefix[l-1] ^ prefixOdd[l-1];
						cout<<ans<<endl;
					}
				}
				else {
					cout<<0<<endl;
				}
			}
			else {
				pass;
			}
		}
	}
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:51:9: warning: statement has no effect [-Wunused-value]
   51 |     pass;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 616 ms 3728 KB Output is correct
2 Correct 666 ms 3936 KB Output is correct
3 Correct 618 ms 3732 KB Output is correct
4 Correct 592 ms 3796 KB Output is correct
5 Correct 607 ms 3828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -