A3: Cyclic Shift Oracle I

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 200 points

Problem Statement

You are given an integer nn.

Implement the following operation on a quantum circuit qc\mathrm{qc} with nn qubits for an arbitrary nn-bit string x0x1⋯xn−1x_0 x_1 \cdots x_{n-1}.

∣x0x1⋯xn−1⟩n→qc∣xn−1x0x1⋯xn−2⟩n\begin{equation} \ket{x_0 x_1 \cdots x_{n-1}}_n \xrightarrow{\mathrm{qc}} \ket{x_{n-1} x_0 x_1 \cdots x_{n-2}}_n \nonumber \end{equation}

Constraints

  • 2≤n≤102 \leq n \leq 10
  • The quantum circuit depth must not exceed 3030.
  • Global phase is ignored in judge.
  • You cannot use Qiskit's SwapGate in this problem.
  • 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=2n = 2: Implemented quantum circuit qc\mathrm{qc} should perform the following transformation. {∣00⟩→qc∣00⟩∣10⟩→qc∣01⟩∣01⟩→qc∣10⟩∣11⟩→qc∣11⟩\begin{equation} \begin{cases} \ket {00} \xrightarrow{\mathrm{qc}} \ket{00} \\ \ket {10} \xrightarrow{\mathrm{qc}} \ket{01} \\ \ket {01} \xrightarrow{\mathrm{qc}} \ket{10} \\ \ket {11} \xrightarrow{\mathrm{qc}} \ket{11} \end{cases} \nonumber \end{equation}

Please sign in to submit your answer.