B7: Reflection Operator III

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 300

Problem Statement

You are given an integer nn and real numbers T0, T1, , Tn1T_0,\ T_1,\ \ldots,\ T_{n-1}. Implement the operation defined by the following matrix AA on a quantum circuit qc\mathrm{qc} with nn qubits:

A=2ψψIA = 2 \ket{\psi}\bra{\psi} - I

where II denotes the 2n×2n2^n \times 2^n identity matrix and ψ\ket{\psi} is defined by

ψ=(cosT00+sinT01)(cosT10+sinT11)(cosTn10+sinTn11).\ket{\psi} = (\cos T_0 \ket{0} + \sin T_0\ket{1}) (\cos T_1\ket{0} + \sin T_1\ket{1}) \ldots (\cos T_{n-1} \ket{0} + \sin T_{n-1} \ket{1}).

Constraints

  • 2n102 \leq n \leq 10
  • π<Tiπ- \pi \lt T_i \leq \pi
  • Global phase is ignored in judge.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int, T: list[float]) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Hints

Open
  • You can apply the inverse gate or the inverse circuit as follows:
qc.compose(sub_qc().inverse(), inplace=True)
# def sub_qc() -> QuantumCircuit

Please sign in to submit your answer.