이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/// tree bends in youth
/// 24.01.2024
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N = 5e3 + 5;
const ll maxn =1e6 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll LG = 18;
int a[N];
void solve(){
int n,q;cin >> n >> q;
if(max(n,q) <= 500){
for(int i = 1;i <= n;i++){
cin >> a[i];
}
while(q--){
int tp;cin >> tp;
if(tp == 1){
int i,j;cin >> i >> j;
a[i] = j;
}
else{
int l,r;cin >> l >> r;
int ans = 0;
for(int i = l;i <= r;i++){
int x = 0;
for(int j = i;j >= l;j--){
x = (x ^ a[j]);
ans = (ans ^ x);
}
}
cout << ans << '\n';
}
}
}
else if(max(n,q) <= 5000){
for(int i = 1;i <= n;i++){
cin >> a[i];
}
while(q--){
int tp;cin >> tp;
if(tp == 1){
int i,j;cin >> i >> j;
a[i] = j;
}
else{
int l,r;cin >> l >> r;
int ans = 0;
for(int i = l;i <= r;i++){
int ql =(i - l+ 1 );
int qr = (r - i + 1);
int res = (ql * qr);
if(res % 2 == 1){
ans= (ans ^ a[i]);
}
}
cout << ans << '\n';
}
}
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("haybales.in","r",stdin);
// freopen("haybales.out","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
xoranges.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
69 | main (){
| ^~~~
# | 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... |