이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lop(i,a,b) for(ll i = a; i < b; i++)
#define alop(i,v) for(auto &i: v)
#define in(v) for(auto &i: v) cin >> i;
#define ll long long
//#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(dp, x) memset(dp, x, sizeof(dp))
using namespace std;
const ll mod = 1e9 + 7;
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, q; cin >> n >> q;
ll arr[n]; in(arr);
ll pre0[n] = {}, pre1[n] = {};
pre0[0] = pre0[1] = arr[0], pre1[1] = arr[1];
for(int i = 2; i < n; i++){
if(i % 2 == 0)
pre0[i] ^= arr[i];
else
pre1[i] ^= arr[i];
pre0[i] ^= pre0[i - 1];
pre1[i] ^= pre1[i - 1];
}
while(q--){
ll t, l, r; cin >> t >> l >> r;
l--, r--;
ll len = r - l + 1;
if(len == 1){
cout << arr[l];
continue;
}
else if(len % 2 == 0){
cout << 0;
continue;
}
else{
if(l % 2 == 0)
cout << (pre1[r] ^ pre1[l]);
else
cout << (pre0[r] ^ pre0[l]);
}
cout << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |