codeforces-scrape

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

1001I.md (1804B)


      1 Source: https://codeforces.com/problemset/problem/1001/I
      2 
      3 I. Deutsch-Jozsa algorithm
      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 a quantum oracle - an operation on *N* + 1 qubits which implements a function ![](https://espresso.codeforces.com/ca923da5e61e139eb5596a3b9e34cc7ef42d1433.png). You are guaranteed that the function *f* implemented by the oracle is either constant (returns 0 on all inputs or 1 on all inputs) or balanced (returns 0 on exactly one half of the input domain and 1 on the other half).
     22 
     23 There are only two possible constant functions: *f*(*x*) = 0 and *f*(*x*) = 1. The functions implemented by oracles in the two previous problems (*f*(*x*) = *x**k* and ![](https://espresso.codeforces.com/601fd91df91c2fbae106d1ddc30f35b042b484e0.png)) are examples of balanced functions.
     24 
     25 Your task is to figure out whether the function given by the oracle is constant. Your code is allowed to call the given oracle only once.
     26 
     27 Input
     28 
     29 You have to implement an operation which takes the following inputs:
     30 
     31 * an integer *N* - the number of qubits in the oracle input,
     32 * an oracle *Uf*, implemented as an operation with signature ((Qubit[], Qubit) => ()), i.e., an operation which takes as input an array of qubits and an output qubit and has no output.
     33 
     34 The return of your operation is a Boolean value: true if the oracle implements a constant function and false otherwise.
     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 (N : Int, Uf : ((Qubit[], Qubit) => ())) : Bool  
     44     {  
     45         body  
     46         {  
     47             // your code here  
     48         }  
     49     }  
     50 }
     51 ```