codeforces-scrape

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

1002B2.md (1155B)


      1 Source: https://codeforces.com/problemset/problem/1002/B2
      2 
      3 B2. Distinguish GHZ state and W 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 (2 ≤ *N* ≤ 8) which are guaranteed to be in one of the two states:
     22 
     23 * ![](https://espresso.codeforces.com/acb08ce15c611d90dc85f731accccd9bbfac8fd3.png) state, or
     24 * ![](https://espresso.codeforces.com/6c9f6af141e015f20a73dd1c0e8749da68f71ba6.png) state.
     25 
     26   Your task is to perform necessary operations and measurements to figure out which state it was and to return 0 if it was GHZ state or 1 if it was W state. The state of the qubits after the operations does not matter.
     27 
     28   You have to implement an operation which takes an array of *N* qubits as an input and returns an integer.
     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 (qs : Qubit[]) : Int  
     38       {  
     39           body  
     40           {  
     41               // your code here  
     42           }  
     43       }  
     44   }
     45   ```