1115G3.md (1120B)
1 Source: https://codeforces.com/problemset/problem/1115/G3 2 3 G3. Palindrome checker oracle 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Implement a quantum oracle on $N$ qubits which checks whether the vector $\vec{x}$ is a palindrome (i.e., implements the function $f(\vec{x}) = 1$ if $\vec{x}$ is a palindrome, and 0 otherwise). 22 23 You have to implement an operation which takes the following inputs: 24 25 * an array of $N$ ($1 \le N \le 8$) qubits $x$ in an arbitrary state (input register), 26 * a qubit $y$ in an arbitrary state (output qubit), 27 28 and performs a transformation $|x\rangle|y\rangle \rightarrow |x\rangle|y \oplus f(x)\rangle$. The operation doesn't have an output; its "output" is the state in which it leaves the qubits. 29 30 Your code should have the following signature: 31 32 ``` 33 namespace Solution { 34 open Microsoft.Quantum.Primitive; 35 open Microsoft.Quantum.Canon; 36 37 operation Solve (x : Qubit[], y : Qubit) : Unit { 38 body (...) { 39 // your code here 40 } 41 adjoint auto; 42 } 43 } 44 ```