A3: Cyclic Shift Oracle I

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

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 bit string.

x0x1xn1nqcxn1x0x1xn2n\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

  • 2n102 \leq n \leq 10
  • The circuit depth must not exceed 3030.
  • Global phase is ignored in judge.
  • You cannnot 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 circuit qc\mathrm{qc} should perform the following transformation. {00qc0010qc0101qc1011qc11\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.