CSES - Aalto Competitive Programming 2024 - wk4 - Mon - Results
Submission details
Task:Xor sum
Sender:hungdojan
Submission time:2024-09-23 16:20:34 +0300
Language:C++ (C++11)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.35 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

#define I_2D(row, col, width) ((row) * (width) + (col))
#define PRINT_ARR(arr, n)                                                      \
  do {                                                                         \
    for (int i = 0; i < n; i++) {                                              \
      cout << arr[i] << " ";                                                   \
    }                                                                          \
    cout << "\n";                                                              \
  } while (0)

typedef long long ll;

#define DEF_VAL 0

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, q;
  cin >> n >> q;

  ll arr[n];
  memset(arr, 0, n*sizeof(ll));

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i != 0) {
      arr[i] ^= arr[i-1];
    }
  }

  int a, b;
  ll s;
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    a--, b--;
    s = arr[b];
    if (a > 0) {
      s ^= arr[a-1];
    }
    cout << s << endl;
  }
  return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
8 36
7 6 4 6 2 9 4 8
1 1
1 2
1 3
...

correct output
7
1
5
3
1
...

user output
7
1
5
3
1
...

Test 2

Verdict: ACCEPTED

input
200000 200000
921726510 307633388 992247073 ...

correct output
834756431
130379787
403037296
308618218
784778243
...

user output
834756431
130379787
403037296
308618218
784778243
...
Truncated