Submission #947520

#TimeUsernameProblemLanguageResultExecution timeMemory
947520asdfghjkXORanges (eJOI19_xoranges)C++17
55 / 100
29 ms604 KiB
/// 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(); } }

Compilation message (stderr)

xoranges.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main (){
      | ^~~~
#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...