Submission #1246278

#TimeUsernameProblemLanguageResultExecution timeMemory
1246278nanaseyuzukiXORanges (eJOI19_xoranges)C++20
100 / 100
53 ms3912 KiB
#include <bits/stdc++.h> /* --> Author: Kazuki_Hoshino__8703 <-- I love Nanasaki Ai ☆*: .。. o(≧▽≦)o .。.:*☆ */ #define fi first #define se second #define pii pair<int, int> #define ll long long using namespace std; const int mn = 3e5 + 5, bm = (1 << 15) + 1, mod = 1e9 + 7; const ll inf = 1e9 + 7, base = 311; int n, q, a[mn]; int bit[2][mn]; void add(int x, int u, int val){ while(u <= n){ bit[x][u] ^= val; u += (u & -u); } } int get(int x, int u){ int res = 0; while(u > 0){ res ^= bit[x][u]; u -= (u & -u); } return res; } void solve(){ cin >> n >> q; for(int i = 1; i <= n; i++){ cin >> a[i]; add(i % 2, i, a[i]); } while(q--){ int t, l, r; cin >> t >> l >> r; if(t == 1){ add(l % 2, l, a[l]); add(l % 2, l, r); a[l] = r; } else{ int len = r - l + 1; if(len % 2 == 0) cout << 0 << '\n'; else{ int id = l % 2; cout << (get(id, r) ^ get(id, l - 1)) << '\n'; } } } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); if(fopen("ROBOT.INP", "r")){ freopen("ROBOT.INP", "r", stdin); freopen("ROBOT.OUT", "w", stdout); } int t = 1; // cin >> t; while(t --){ solve(); } }

Compilation message (stderr)

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