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

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 600 points

Problem Statement

You are given an integer nn, a real number PP, 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≤∣⟨ω∣U∣0⟩∣2≤4PP \leq \left|\braket{\omega \mid U \mid 0}\right|^2 \leq 4P
  • R(θ)=I−(1−eiθ)∣ω⟩⟨ω∣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 ∣⟨ω∣O∣0⟩∣2≥0.99\left|\braket{\omega \mid O \mid 0}\right|^2 \geq 0.99 within an error of 0.010.01.

Constraints

  • 1≤n≤51 \leq n \leq 5
  • 0.02≤P≤10.02 \leq P \leq 1
  • The number of applied R(⋅)R(\cdot) must not exceed 100100. (If exceeded, a DLE (depth limit exceeded) error will be displayed)
  • Global phase is ignored in judge.
  • 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.