B3: SWAP Qubits

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Problem Statement

Implement the operation of swapping two qubit states on a quantum circuit qc\mathrm{qc} with 22 qubits.

More precisely, implement the operation defined as

a000+a110+a201+a311qca000+a210+a101+a311,\begin{equation} a_0\ket{00} + \underline{a_1}\ket{10} + \underline{a_2}\ket{01} + a_3\ket{11} \xrightarrow{\mathrm{qc}} a_0\ket{00} + \underline{a_2}\ket{10} + \underline{a_1}\ket{01} + a_3\ket{11} \nonumber \end{equation},

where aia_i represents arbitrary probability amplitudes.

Constraints

  • You cannnot use Qiskit's SwapGate in this problem.
  • Changes in the global phase are ignored.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
    # Write your code here:
 
    return qc

Please sign in to submit your answer.