B2: Convert Bit-Flip into Phase-Flip I

実行時間制限:3 秒

メモリ制限:512 MiB

配点:200点

問題文

整数 nn と オラクル OO が入力として与えられる。 オラクル OO は 0≤x<2n0\leq x\lt 2^n と 0≤y<20\leq y\lt 2 を満たす任意の整数の組 (x,y)(x,y) に対して、次式を満たす。

∣x⟩n∣y⟩1→O∣x⟩n∣y⊕f(x)⟩1\ket{x}_n \ket{y}_1 \xrightarrow{O} \ket{x}_n \ket{y \oplus f(x)}_1

ただし、⊕\oplus は排他的論理和を表し、関数 f(x)f(x) は 00 以上 2n2^n 未満の整数 xx に対して、00 または 11 のどちらかを返す。

0≤x<2n0\leq x\lt 2^n を満たす任意の整数 xx に対して

∣x⟩n∣0⟩1→qc{−∣x⟩n∣0⟩1(f(x)=1)∣x⟩n∣0⟩1(f(x)=0)\begin{equation} \ket{x}_n\ket{0}_1 \xrightarrow{\mathrm{qc}} \begin{cases} - \ket{x}_n\ket{0}_1 & (f(x) = 1) \\ \ket{x}_n\ket{0}_1 & (f(x) = 0) \end{cases} \nonumber \end{equation}

を満たす操作を n+1n+1 量子ビットをもつ量子回路 qc\mathrm{qc} 上に実装せよ。

制約

from qiskit import QuantumCircuit, QuantumRegister
 
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
 
 
def solve(n: int, o: QuantumCircuit) -> QuantumCircuit:
    x, y = QuantumRegister(n), QuantumRegister(1)
    qc = QuantumCircuit(x, y)
    # Write your code here:
 
    return qc

入力例

  • n=2, (f(00),f(10),f(01),f(11))=(0,1,0,1)n = 2,\ (f(00), f(10), f(01), f(11)) = (0, 1, 0, 1): 実装された量子回路 qc\mathrm{qc} は次式を満たす。 14(∣00⟩+∣10⟩+∣01⟩+∣11⟩)∣0⟩→qc14(∣00⟩−∣10⟩+∣01⟩−∣11⟩)∣0⟩\frac{1}{\sqrt{4}} ( \ket{00}+\ket{10}+\ket{01}+\ket{11} )\ket{0} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{4}} (\ket{00} - \ket{10} + \ket{01} - \ket{11})\ket{0}

解答を提出するにはログインしてください。