Submission #1181357

#TimeUsernameProblemLanguageResultExecution timeMemory
1181357nguynXORanges (eJOI19_xoranges)C++20
100 / 100
51 ms3912 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 2e5 + 5; struct BIT { int n; vector<int> bit; BIT () {} BIT (int n) : n(n) { bit.assign(n + 3, 0); } void update(int id, int val) { for (int i = id; i <= n; i += (i & -i)) bit[i] ^= val; } int get(int id) { int res = 0; for (int i = id; i; i -= (i & -i)) res ^= bit[i]; return res; } int get(int l, int r) { return get(r) ^ get(l - 1); } } bit[2]; int n, q; int a[N]; signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n >> q; bit[0] = BIT(n); bit[1] = BIT(n); for (int i = 1; i <= n; i++) { cin >> a[i]; bit[i & 1].update(i, a[i]); } while(q--) { int type; cin >> type; if (type == 1) { int i, j; cin >> i >> j; bit[i & 1].update(i, a[i]); a[i] = j; bit[i & 1].update(i, a[i]); } if (type == 2) { int l, r; cin >> l >> r; if (l & 1) { if (r & 1) { cout << bit[1].get(l, r); } else { cout << 0; } } else { if (r & 1) { cout << 0; } else { cout << bit[0].get(l, r); } } cout << '\n'; } } }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen("OUT.OUT" , "w" , stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...