Ex: Can you prepare ω?\ket{\omega}?

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 600

Problem Statement

You are given an integer nn, a real number θ\theta, an nn-qubit quantum gate UU and an nn-qubit parametric quantum gate R()R(\cdot) of unknown structures.

There exists a vector ω\ket{\omega} satisfying the following two conditions:

  • PωU024PP \leq \left|\braket{\omega \mid U \mid 0}\right|^2 \leq 4P
  • R(θ)=I(1eiθ)ωωR(\theta) = I - (1 - e^{i\theta})\ket{\omega}\bra{\omega}

Using the quantum gates UU and R()R(\cdot), implement an operation OO that prepares the quantum state ω\ket{\omega} on a quantum circuit qc\mathrm{qc} with nn qubits.

The operation OO must satisfy ωO020.99\left|\braket{\omega \mid O \mid 0}\right|^2 \geq 0.99 within an error of 0.010.01.

Constraints

  • 1n51 \leq n \leq 5
  • 0.02P10.02 \leq P \leq 1
  • The number of applications of R()R(\cdot) must not exceed 100100. (If exceeded, a DLE (depth limit exceeded) error will be displayed)
  • Changes in the global phase are ignored.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
"""
You can apply U and R as follows:
qc.compose(U(), inplace=True)
qc.compose(R(theta), inplace=True)
"""
 
 
def solve(n: int, P: float, U, R) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Hints

Open
  • You can use the inverse gates of the quantum gates UU and R()R(\cdot).
qc.compose(U().inverse(), inplace=True)
qc.compose(R(theta).inverse(), inplace=True)

Please sign in to submit your answer.