eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Queries on anti-xor

Queries on anti-xor

Recently our coach - Etibar has invented a new bitwise operation. It is like a reverse of xor operation. Then called it as anti-xor. Now he is giving you a new problem which is related to his invention on queries. The sign of anti-xor is #. You are given \textbf{N} number. Perform the following operations on those integers. 1) Anti-xor \textbf{X} with integer from \textbf{L} to \textbf{R}. This query is represented as “\textbf{1 L R X}” 2) Output the sum of all numbers from \textbf{L} to \textbf{R}. This query is represented as “\textbf{2 L R}” Assume that all numbers are \textbf{20} bits integers. So you do anti-xor operation on last \textbf{20} bits. \InputFile You are given an integer N (\textbf{1} ≤ \textbf{N} ≤ \textbf{100000}). In the second line you are given \textbf{N} integers (\textbf{0} ≤ \textbf{A_i} ≤ \textbf{10^6}). The next line contains the number of queries \textbf{Q} (\textbf{1} ≤ \textbf{Q} ≤ \textbf{100000}). Each of the next \textbf{Q} lines contains one query of one of the forms above. \OutputFile For each query of the type “\textbf{2 L R}” print on a separate line the sum of all integers from \textbf{L} to \textbf{R}.
Лимит времени 2.5 секунды
Лимит использования памяти 64 MiB
Входные данные #1
5
4 6 10 123 456
6
1 1 5 6
1 3 4 10
2 2 5
1 2 4 7
2 1 5
2 2 3
Выходные данные #1
2096813
4193730
1048581
Автор Mahammad Valiyev
Источник Local Contest #2 Qafqaz University by Mahammad Valiyev