Submission #972600

#TimeUsernameProblemLanguageResultExecution timeMemory
972600njoopXORanges (eJOI19_xoranges)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, q, od[600010], ev[600010], c, id, va, in, st, en, f, s, enu, onu; void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) { if(l == r) { seg[node] = val; return; } int mid = (l+r)>>1; if(idx <= mid) update(l, mid, idx, val, node*2, seg); else update(mid+1, r, idx, val, node*2+1, seg); seg[node] = seg[node*2]^seg[node*2+1]; } int query(int l, int r, int ql, int qr, int node, int (&seg)[400010]) { if(l > qr || r < ql) return 0; if(l >= ql && r <= qr) return seg[node]; int mid = (l+r)>>1; return query(l, mid, ql, qr, node*2, seg)^query(mid+1, r, ql, qr, node*2+1, seg); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> q; for(int i=1; i<=n; i++) { cin >> in; if(i%2) { update(1, n, i, in, 1, od); } else { update(1, n, i, in, 1, ev); } } while(q--) { cin >> c; if(c == 1) { cin >> id >> va; if(id%2 == 0) update(1, n, id, va, 1, ev); else update(1, n, id, va, 1, od); } else { cin >> st >> en; if((en-st)%2) cout << 0 << "\n"; else if(st%2) { cout << query(1, n, st, en, 1, od) << "\n"; } else { cout << query(1, n, st, en, 1, ev) << "\n"; } } } return 0; }

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:31:36: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   31 |             update(1, n, i, in, 1, od);
      |                                    ^~
xoranges.cpp:7:61: note: in passing argument 6 of 'void update(int, int, int, int, int, int (&)[400010])'
    7 | void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) {
      |                                                       ~~~~~~^~~~~~~~~~~~
xoranges.cpp:33:36: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   33 |             update(1, n, i, in, 1, ev);
      |                                    ^~
xoranges.cpp:7:61: note: in passing argument 6 of 'void update(int, int, int, int, int, int (&)[400010])'
    7 | void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) {
      |                                                       ~~~~~~^~~~~~~~~~~~
xoranges.cpp:40:51: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   40 |             if(id%2 == 0) update(1, n, id, va, 1, ev);
      |                                                   ^~
xoranges.cpp:7:61: note: in passing argument 6 of 'void update(int, int, int, int, int, int (&)[400010])'
    7 | void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) {
      |                                                       ~~~~~~^~~~~~~~~~~~
xoranges.cpp:41:42: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   41 |             else update(1, n, id, va, 1, od);
      |                                          ^~
xoranges.cpp:7:61: note: in passing argument 6 of 'void update(int, int, int, int, int, int (&)[400010])'
    7 | void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) {
      |                                                       ~~~~~~^~~~~~~~~~~~
xoranges.cpp:46:48: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   46 |                 cout << query(1, n, st, en, 1, od) << "\n";
      |                                                ^~
xoranges.cpp:18:57: note: in passing argument 6 of 'int query(int, int, int, int, int, int (&)[400010])'
   18 | int query(int l, int r, int ql, int qr, int node, int (&seg)[400010]) {
      |                                                   ~~~~~~^~~~~~~~~~~~
xoranges.cpp:48:48: error: invalid initialization of reference of type 'int (&)[400010]' from expression of type 'int [600010]'
   48 |                 cout << query(1, n, st, en, 1, ev) << "\n";
      |                                                ^~
xoranges.cpp:18:57: note: in passing argument 6 of 'int query(int, int, int, int, int, int (&)[400010])'
   18 | int query(int l, int r, int ql, int qr, int node, int (&seg)[400010]) {
      |                                                   ~~~~~~^~~~~~~~~~~~