제출 #478058

#제출 시각아이디문제언어결과실행 시간메모리
478058pragmatistXORanges (eJOI19_xoranges)C++14
55 / 100
1079 ms1932 KiB
#include <bits/stdc++.h>                       
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()
#define x first
#define y second
#define int long long         
#define nl "\n"
 
using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;

const int N = (int)3e5 + 7;
const int M = (int)7e6 + 7;
const ll MOD = (ll)1e9 + 7;                    
const int inf = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

int n, q, a[N];

void solve() {
	cin >> n >> q;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	if(n <= 5000 && q <= 5000) {
		while(q--) {
			char c;
			cin >> c;
			int l, r;
			cin >> l >> r;
			if(c == '1') a[l] = r;
			else {
				int res = 0;
				if(((r - l + 1) & 1) == 0) {
					cout << "0\n";
					continue;
				}
				for(int i = l; i <= r; ++i) {
					int x = (i-l+1) * (r-i+1);
					if(x & 1) res ^= a[i];
					//cout << (x & 1) << ' ';
				}
				//cout << nl;
				cout << res << nl;
			}
		}
		return;
	}
	while(q--) {
		char c;
		cin >> c;
		int l, r;
		cin >> l >> r;
		int res = 0;
		for(int i = l; i <= r; ++i) {
			int x = (i-l+1) * (r-i+1);
			if(x & 1) res ^= a[i];
		}
		cout << res << nl;			
	}
	
} 

signed main() {                   
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1;                       
	//cin >> test;
	for(int i = 1; i <= test; i++) {
        //cout << "Case " << i << ":\n";
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...