codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

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 ![](https://espresso.codeforces.com/b2eb3d0e407b200708fe5e4dc65e777bc2c88984.png)
     24 
     25 Here ![](https://espresso.codeforces.com/b27ec8b8056386de828da0df174348afa7d29512.png) (a vector of *N* integers, each of which can be 0 or 1), and ![](https://espresso.codeforces.com/823bed8a1021f190960cf0b721fad709b7641d0e.png) 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 ![](https://espresso.codeforces.com/71fa108edb785ca9f729fa3cd5ad18556dd682e4.png). 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 ```