A5: Generate State 12(02n1)\frac{1}{\sqrt{2}}\lparen\ket{0}-\ket{2^{n}-1}\rparen III

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 quantum state ψ\ket{\psi} is defined as

ψ=12(0...0n1...1n)\begin{equation} \ket{\psi} = \frac{1}{\sqrt{2}} (\ket{\underbrace{0...0}_n} - \ket{\underbrace{1...1}_n}) \nonumber \end{equation}

Constraints

  • 2n152 \leq n \leq 15
  • The circuit depth must not exceed 66.
  • Changes in the global phase are ignored.
  • 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
    The implemented quantum circuit qc\mathrm{qc} should perform the following transformation.
0000qc12(00001111)\ket{0000} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{2}} (\ket{0000} - \ket{1111})

Please sign in to submit your answer.