제출 #1255069

#제출 시각아이디문제언어결과실행 시간메모리
1255069minggaXORanges (eJOI19_xoranges)C++20
100 / 100
53 ms3912 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; const int N = 2e5 + 7; int n, q, a[N]; struct BIT { int n; vector<int> bit; BIT() {} BIT(int n) : n(n) { bit.resize(n + 1, 0); } void update(int u, int x) { for(; u <= n; u += (u & -u)) { bit[u] ^= x; } } int get(int u) { int ans = 0; for(; u > 0; u -= (u & -u)) { ans ^= bit[u]; } return ans; } int get(int l, int r) { return get(r) ^ get(l - 1); } } bit[2]; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n >> q; for(int i = 1; i <= n; i++) cin >> a[i]; bit[0] = bit[1] = BIT(n); for(int i = 1; i <= n; i++) { bit[i & 1].update(i, a[i]); } for(int i = 1; i <= q; i++) { int t, u, v; cin >> t >> u >> v; if(t == 1) { bit[u & 1].update(u, v ^ a[u]); a[u] = v; } else { if((v - u + 1) & 1) { int id = u & 1; cout << bit[id].get(u, v); } else cout << 0; cout << ln; } } cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

컴파일 시 표준 에러 (stderr) 메시지

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