{ "schema": "wai.quantum.exercise/1", "id": "grover", "translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" }, "title": { "en": "Searching by amplitude", "zh-CN": "靠振幅来搜索" }, "task": { "en": "Two qubits in uniform superposition, and an oracle that marks 11 with a minus sign. Add the diffusion step so that one round of Grover's search finds 11 every time. No two gates of your program may cancel.", "zh-CN": "两个处于均匀叠加的量子比特,以及一个用负号标记 11 的预言机。加上扩散(diffusion)步骤,使一轮 Grover 搜索每次都找到 11。程序中不得有相互抵消的门。" }, "starter": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "// the oracle: a minus sign on 11", "cz q[0], q[1];", "// the diffusion: your gates here", "c = measure q;" ], "intent": { "distribution": { "11": 1.0 } }, "constraints": { "allow": ["h", "x", "z", "cz"], "counts": { "cz": { "min": 2, "max": 2 } }, "no_smells": ["cancels", "merges", "does_nothing"] }, "hints": { "en": [ "The oracle's sign is invisible to a measurement: the outcomes are still uniform. The diffusion turns it into amplitude.", "The diffusion reflects every amplitude about their average. Built from gates, it is a sign on 00 between two layers of Hadamards.", "To put a sign on 00 with cz, which signs 11, flip both qubits before and after it." ], "zh-CN": [ "预言机加上的符号在测量中是看不见的:结果仍然是均匀的。扩散步骤把它变成振幅上的差别。", "扩散步骤把每个振幅关于它们的平均值作反射。用门来搭建时,它就是夹在两层 Hadamard 门之间、加在 00 上的一个符号。", "cz 给 11 加符号;要用它给 00 加符号,就在它前后把两个量子比特都翻转。" ] }, "reference": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "cz q[0], q[1];", "h q;", "x q;", "cz q[0], q[1];", "x q;", "h q;", "c = measure q;" ], "wrong": [ { "fails": "intent", "note": "the oracle alone leaves the outcomes uniform", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "cz q[0], q[1];", "c = measure q;"] }, { "fails": "constraint", "note": "undoing the oracle and flipping both qubits finds 11 without searching", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[2] q;", "bit[2] c;", "h q;", "cz q[0], q[1];", "cz q[0], q[1];", "h q;", "x q;", "c = measure q;"] } ] }