CF BUDDY
← Problems·

1451E1 · Bitwise Queries (Easy Version)

2000 · bitmasks, constructive algorithms, interactive

Problem: The only difference between the easy and hard versions is the constraints on the number of queries.

This is an interactive problem.

Ridbit has a hidden array aa of nn integers which he wants Ashish to guess. Note that nn is a power of two. Ashish is allowed to ask three different types of queries. They are of the form

  • AND ii jj: ask for the bitwise AND of elements aia_i and aja_j (1i,jn(1 \leq i, j \le n, ij)i \neq j)
  • OR ii jj: ask for the bitwise OR of elements aia_i and aja_j (1i,jn(1 \leq i, j \le n, ij)i \neq j)
  • XOR ii jj: ask for the bitwise XOR of elements aia_i and aja_j (1i,jn(1 \leq i, j \le n, ij)i \neq j)

Can you help Ashish guess the elements of the array?

In this version, each element takes a value in the range [0,n1][0, n-1] (inclusive) and Ashish can ask no more than n+2n+2 queries.

Input Format: The first line of input contains one integer nn (4n216)(4 \le n \le 2^{16}) — the length of the array. It is guaranteed that nn is a power of two.

Note: The array aa in the example is [0,0,2,3][0, 0, 2, 3].

Sample Cases

Case 1

Input

4

0

2

3

Output

OR 1 2

OR 2 3

XOR 2 4

! 0 0 2 3

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback