codeforces-scrape

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

1001G.md (1205B)


      1 Source: https://codeforces.com/problemset/problem/1001/G
      2 
      3 G. Oracle for f(x) = k-th element of x
      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 a function *f*(*x*) = *x**k*, i.e. the value of the function is the value of the *k*-th qubit.
     22 
     23 For an explanation on how the quantum oracles work, see [the tutorial blog post](https://codeforces.com/blog/entry/60319).
     24 
     25 Input
     26 
     27 You have to implement an operation which takes the following inputs:
     28 
     29 * an array of qubits *x* (input register),
     30 * a qubit *y* (output qubit),
     31 * 0-based index of the qubit from input register *K* (![](https://espresso.codeforces.com/cba82dd0812bfc7c740101e78cd264732de29b22.png)).
     32 
     33 The operation doesn't have an output; the "output" of your solution is the state in which it left the qubits.
     34 
     35 Your code should have the following signature:
     36 
     37 ```
     38 namespace Solution {  
     39     open Microsoft.Quantum.Primitive;  
     40     open Microsoft.Quantum.Canon;  
     41   
     42     operation Solve (x : Qubit[], y : Qubit, k : Int) : ()  
     43     {  
     44         body  
     45         {  
     46             // your code here  
     47         }  
     48     }  
     49 }
     50 ```