B4: Less Than Oracle II

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 500

Problem Statement

You are given integers nn and LL.
Implement the oracle OO on a quantum circuit qc\mathrm{qc} with nn qubits, which multiplies all the probability amplitudes aia_i of 0, 1, ... L1\ket{0},\ \ket{1},\ ...\ \ket{L-1} by 1-1.

Constraints

  • 1n101 \leq n \leq 10
  • 1L2n1 \leq L \leq 2^n
  • The circuit depth must not exceed 5050.
  • Changes in the global phase are ignored.
  • Integers are encoded by little-endian notation, i.e., 100=1001\ket{100} = 1 \neq \ket{001}.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Sample Input

  • n=2, L=3n = 2,\ L=3
    The implemented oracle OO should perform the following transformation.
14(00+10+01+11)O14(001001+11)\frac{1}{\sqrt{4}} (\ket{00} + \ket{10} + \ket{01} + \ket{11}) \xrightarrow{O} \frac{1}{\sqrt{4}} (-\ket{00} - \ket{10} - \ket{01} + \ket{11})

Please sign in to submit your answer.