codeforces-scrape

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

1002A3.md (1714B)


      1 Source: https://codeforces.com/problemset/problem/1002/A3
      2 
      3 A3. Generate superposition of two basis states
      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 two bitstrings *bits*0 and *bits*1 which describe two different basis states on *N* qubits ![](https://espresso.codeforces.com/07ea1d435b195752acd41643cb12df28e6913e88.png) and ![](https://espresso.codeforces.com/0648292c6f022bae2c3c2bc8fb76f00714a57bd9.png).
     22 
     23 Your task is to generate a state which is an equal superposition of the given basis states:
     24 
     25 ![](https://espresso.codeforces.com/8bca7f237006a9be77ba507b8c1faac217c6a5b3.png)
     26 
     27 You have to implement an operation which takes the following inputs:
     28 
     29 * an array of qubits *qs*,
     30 * two arrays of Boolean values *bits*0 and *bits*1 representing the basis states ![](https://espresso.codeforces.com/07ea1d435b195752acd41643cb12df28e6913e88.png) and ![](https://espresso.codeforces.com/0648292c6f022bae2c3c2bc8fb76f00714a57bd9.png). These arrays will have the same length as the array of qubits. *bits*0 and *bits*1 will differ in at least one position.
     31 
     32 The operation doesn't have an output; its "output" is the state in which it leaves the qubits.
     33 
     34 Your code should have the following signature:
     35 
     36 ```
     37 namespace Solution {  
     38     open Microsoft.Quantum.Primitive;  
     39     open Microsoft.Quantum.Canon;  
     40   
     41     operation Solve (qs : Qubit[], bits0 : Bool[], bits1 : Bool[]) : ()  
     42     {  
     43         body  
     44         {  
     45             // your code here  
     46         }  
     47     }  
     48 }
     49 ```