A4: Cyclic Shift Oracle III

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 400

Problem Statement

Given an integer nn, implement an (n+1)(n + 1)-qubit oracle OO on a quantum circuit qc\mathrm{qc}.

The oracle OO acts on basis states knm\ket{k}_n\ket{m}, where 0k<2n0 \leq k < 2^n and 0m<20 \leq m < 2, as follows:

knmOmkn.\ket{k}_n \ket{m} \xrightarrow{O} \ket{m} \ket{k}_n.

Constraints

  • 1n101 \leq n \leq 10
  • The circuit depth must not exceed 44.
  • Integers must be encoded by little-endian.
  • 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 + 1)
    # Write your code here:
 
    return qc

Hints

Open

Please sign in to submit your answer.