{"problem":{"name":"D. Distinguish plus state and minus state","description":{"content":"You are given a qubit which is guaranteed to be either in or in state. Your task is to perform necessary operations and measurements to figure out which state it was and to return 1 if it was a state","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF1001D"},"statements":[{"statement_type":"Markdown","content":"You are given a qubit which is guaranteed to be either in or in state.\n\nYour task is to perform necessary operations and measurements to figure out which state it was and to return 1 if it was a state or -1 if it was state. The state of the qubit after the operations does not matter.\n\n## Input\n\nYou have to implement an operation which takes a qubit as an input and returns an integer.\n\nYour code should have the following signature:\n\nnamespace Solution {\n    open Microsoft.Quantum.Primitive;\n    open Microsoft.Quantum.Canon;\n\n    operation Solve (q : Qubit) : Int\n    {\n        body\n        {\n            // your code here\n        }\n    }\n}\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"给定一个量子比特，其状态保证为 $\\ket{0}$ 或 $\\ket{1}$ 状态。\n\n你的任务是执行必要的操作和测量，以确定它原本处于哪种状态，并在它是 $\\ket{1}$ 状态时返回 1，在它是 $\\ket{0}$ 状态时返回 -1。操作后量子比特的状态无关紧要。\n\n你需要实现一个操作，该操作以量子比特作为输入并返回一个整数。\n\n你的代码应具有以下签名：\n\n## Input\n\n你需要实现一个操作，该操作以量子比特作为输入并返回一个整数。你的代码应具有以下签名：namespace Solution {    open Microsoft.Quantum.Primitive;    open Microsoft.Quantum.Canon;    operation Solve (q : Qubit) : Int    {        body        {            // your code here        }    }}\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ \\ket{\\psi} \\in \\{ \\ket{0}, \\ket{1} \\} $ be the unknown initial state of a qubit.\n\n**Objective**  \nDesign a quantum operation that, given $ \\ket{\\psi} $, returns:  \n$$\n\\begin{cases}\n1 & \\text{if } \\ket{\\psi} = \\ket{0} \\\\\n-1 & \\text{if } \\ket{\\psi} = \\ket{1}\n\\end{cases}\n$$  \nusing quantum gates and a measurement in the computational basis. The final state of the qubit is irrelevant.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF1001D","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}