1002D2.md (1586B)
1 Source: https://codeforces.com/problemset/problem/1002/D2 2 3 D2. Oracle for f(x) = b * x + (1 - b) * (1 - x) mod 2 4 5 time limit per test 6 7 1 second 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 implements the following function: 22 23  24 25 Here  (a vector of *N* integers, each of which can be 0 or 1), and  is a vector of *N* 1s. 26 27 For an explanation on how this type of quantum oracles works, see [Introduction to quantum oracles](https://codeforces.com/blog/entry/60319). 28 29 You have to implement an operation which takes the following inputs: 30 31 * an array of *N* qubits *x* in arbitrary state (input register), 1 ≤ *N* ≤ 8, 32 * a qubit *y* in arbitrary state (output qubit), 33 * an array of *N* integers *b*, representing the vector . Each element of *b* will be 0 or 1. 34 35 The operation doesn't have an output; its "output" is the state in which it leaves the qubits. 36 37 Your code should have the following signature: 38 39 ``` 40 namespace Solution { 41 open Microsoft.Quantum.Primitive; 42 open Microsoft.Quantum.Canon; 43 44 operation Solve (x : Qubit[], y : Qubit, b : Int[]) : () 45 { 46 body 47 { 48 // your code here 49 } 50 } 51 } 52 ```