Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* c651 */
- /* AC (0.1s, 11.8MB) */
- #include <iostream>
- using namespace std;
- //
- #ifdef __GNUC__
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #define fread fread_unlocked
- #define putchar putchar_unlocked
- #else
- #define getc getchar
- #endif
- namespace IO
- {
- constexpr int buf_s = 1 << 15;
- static char ch;
- static bool negative;
- inline int getc()
- {
- static char buf[buf_s], *p1 = buf, *p2 = buf;
- return p1 == p2 && (p2 = (p1 = buf) + read(STDIN_FILENO, buf, buf_s), p1 == p2) ? EOF : *p1++;
- }
- inline int nextInt32(int &out)
- {
- if (ch == EOF) return -1;
- static int tmp;
- tmp = 0;
- negative = false;
- ch = getc();
- if (ch != '-' && (ch < '0' || ch > '9'))
- return (ch == EOF ? -1 : ch);
- (ch == '-' ? negative = true : tmp = ch - '0');
- while ((ch = getc()) && ch >= '0' && ch <= '9')
- tmp = tmp * 10 + ch - '0';
- out = (negative ? -tmp : tmp);
- return 1;
- }
- static char s[25];
- static int index;
- inline void printInt32(int x)
- {
- if (x == 0) putchar('0');
- negative = (x < 0 && (x = -x));
- index = 0;
- while (x) s[index++] = x % 10 + '0', x /= 10;
- (negative ? s[index++] = '-' : s[index]);
- while (index) putchar(s[--index]);
- }
- }
- using IO::nextInt32;
- using IO::printInt32;
- //
- auto lowbit = [](const int &x) noexcept { return x & (-x); };
- const int MAXN = 1e6;
- int N, Q, x, y;
- int BIT[MAXN + 2], arr[MAXN + 2];
- int query(int l, int r)
- {
- int ans = 0, ans_ = 0;
- for(;r; r -= lowbit(r))
- ans ^= BIT[r];
- for(--l; l; l -= lowbit(l))
- ans_ ^= BIT[l];
- return ans ^ ans_;
- }
- void updata(int pos, int x)
- {
- x = arr[pos] ^ x;
- for(;pos <= N; pos += lowbit(pos))
- BIT[pos] ^= x;
- }
- int main()
- {
- nextInt32(N);
- nextInt32(Q);
- for(int i = 1; i <= N && nextInt32(x); ++i)
- {
- updata(i, x);
- arr[i] = x;
- }
- for(int i = 0; i < Q; ++i)
- {
- nextInt32(x);
- if(x == 0)
- {
- nextInt32(x);
- nextInt32(y);
- printInt32(query(x, y));
- putchar('\n');
- }
- else
- {
- nextInt32(x);
- nextInt32(y);
- updata(x, y);
- arr[x] = y;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement