A5: Generate One-hot Superposition State II

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Problem Statement

You are given an integer nn. Implement the operation of preparing the state ψ\ket{\psi} from the zero state on a quantum circuit qc\mathrm{qc} with nn qubits.

The state ψ\ket{\psi} is defined as

ψ=1n(10...0n+010...0n++0...01n).\begin{equation} \ket{\psi} = \frac{1}{\sqrt{n}} \lparen \ket{10...0}_n + \ket{010...0}_n + \cdots + \ket{0...01}_n \rparen \nonumber \end{equation}.

Constraints

  • 2n152 \leq n \leq 15
  • The circuit depth must not exceed 2020.
  • Global phase is ignored in judge.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Sample Input

  • n=4n = 4: Implemented circuit qc\mathrm{qc} should perform the following transformation.
0000qc14(1000+0100+0010+0001)\ket{0000} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{4}} (\ket{1000} + \ket{0100} + \ket{0010} + \ket{0001})

Please sign in to submit your answer.