codeforces-scrape

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

1002A2.md (2185B)


      1 Source: https://codeforces.com/problemset/problem/1002/A2
      2 
      3 A2. Generate superposition of zero state and a basis state
      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 You are given *N* qubits (1 ≤ *N* ≤ 8) in zero state ![](https://espresso.codeforces.com/8bb67080da7081bfb802ca6ecc5abc4f4c5ca190.png). You are also given a bitstring *bits* which describes a non-zero basis state on *N* qubits ![](https://espresso.codeforces.com/a2b41145e9f49aa274a587b2f9d65cc9e1009d74.png).
     22 
     23 Your task is to generate a state which is an equal superposition of ![](https://espresso.codeforces.com/8bb67080da7081bfb802ca6ecc5abc4f4c5ca190.png) and the given basis state:
     24 
     25 ![](https://espresso.codeforces.com/3c269ffe47860b0f64815b3a2967fc04eae1158d.png)
     26 
     27 You have to implement an operation which takes the following inputs:
     28 
     29 * an array of qubits *qs*,
     30 * an arrays of boolean values *bits* representing the basis state ![](https://espresso.codeforces.com/a2b41145e9f49aa274a587b2f9d65cc9e1009d74.png). This array will have the same length as the array of qubits. The first element of this array *bits*[0] will be true.
     31 
     32 The operation doesn't have an output; its "output" is the state in which it leaves the qubits.
     33 
     34 An array of boolean values represents a basis state as follows: the *i*-th element of the array is true if the *i*-th qubit is in state ![](https://espresso.codeforces.com/08c9f8a718e14660a9d064a4b3c11e6340bef9c4.png), and false if it is in state ![](https://espresso.codeforces.com/c1f9019c20fc8a9610d31c36ba7860cef0b7c55c.png). For example, array [true; false] describes 2-qubit state ![](https://espresso.codeforces.com/1d2a4e8366f050f00dba1a3eb5c6098a0dfa8d6f.png), and in this case the resulting state should be ![](https://espresso.codeforces.com/3164767c7c3d394bebf51ea277b19f40852bdb01.png).
     35 
     36 Your code should have the following signature:
     37 
     38 ```
     39 namespace Solution {  
     40     open Microsoft.Quantum.Primitive;  
     41     open Microsoft.Quantum.Canon;  
     42   
     43     operation Solve (qs : Qubit[], bits : Bool[]) : ()  
     44     {  
     45         body  
     46         {  
     47             // your code here  
     48         }  
     49     }  
     50 }
     51 ```