Ex2: Find Hidden Number

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 500

Problem Statement

You are given an integer nn and an oracle OO. There exists an integer LL such that 0L<2n0 \leq L \lt 2^n, and we know that LL is one of the powers of 22 (20,21,...2n1)(2^0, 2^1, ... 2^{n-1}). The oracle OO satisfies

xny1O{xny11(x=L)xny1(xL)\ket{x}_n \ket{y}_1 \xrightarrow{O} \begin{cases} \ket{x}_n \ket{y\oplus 1}_1 & (x=L) \\ \ket{x}_n\ket{y}_1 & (x\neq L) \end{cases}

for any pair of integers (x,y)(x,y) satisfying 0x<2n0\leq x\lt 2^n and 0y<20\leq y\lt 2, where \oplus denotes the XOR operator.

Implement an operation on a quantum circuit qc\mathrm{qc} with nn qubits that prepares a quantum state ψ\ket{\psi} from the zero state, such that L\ket{L} is observed with a probability of at least 0.90.9 upon measurement.

More Precise Problem Statement

Define the state ψ\ket{\psi} prepared by qc\mathrm{qc} as

ψ=i=02n1aii,\begin{equation} \ket{\psi} = \sum_{i=0}^{2^n-1} a_i\ket{i}, \nonumber \end{equation}

where aia_i denotes the probability amplitude of the computational basis state i\ket{i}.

Implement qc\mathrm{qc} satisfying following condition:

aL20.9|a_L|^2 \geq 0.9

Constraints

  • 2n102 \leq n \leq 10
  • The circuit depth must not exceed 7575.
  • Oracle OO is given as a quantum circuit of depth 11.
  • Integers must be encoded by little-endian notation, i.e., 100=1001\ket{100} = 1 \neq \ket{001}.
  • Global phase is ignored in judge.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
 
 
def solve(n: int, o: QuantumCircuit) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Please sign in to submit your answer.