D. Distinguish plus state and minus state

Codeforces
IDCF1001D
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
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 or -1 if it was state. The state of the qubit after the operations does not matter. ## Input You have to implement an operation which takes a qubit as an input and returns an integer. Your code should have the following signature: namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit) : Int { body { // your code here } } } [samples]
给定一个量子比特,其状态保证为 $\ket{0}$ 或 $\ket{1}$ 状态。 你的任务是执行必要的操作和测量,以确定它原本处于哪种状态,并在它是 $\ket{1}$ 状态时返回 1,在它是 $\ket{0}$ 状态时返回 -1。操作后量子比特的状态无关紧要。 你需要实现一个操作,该操作以量子比特作为输入并返回一个整数。 你的代码应具有以下签名: ## Input 你需要实现一个操作,该操作以量子比特作为输入并返回一个整数。你的代码应具有以下签名:namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit) : Int { body { // your code here } }} [samples]
**Definitions** Let $ \ket{\psi} \in \{ \ket{0}, \ket{1} \} $ be the unknown initial state of a qubit. **Objective** Design a quantum operation that, given $ \ket{\psi} $, returns: $$ \begin{cases} 1 & \text{if } \ket{\psi} = \ket{0} \\ -1 & \text{if } \ket{\psi} = \ket{1} \end{cases} $$ using quantum gates and a measurement in the computational basis. The final state of the qubit is irrelevant.
API Response (JSON)
{
  "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...",
      "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你需要实现一个操作...",
      "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{ca...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments