B. Generate Bell state

Codeforces
IDCF1001B
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given two qubits in state and an integer _index_. Your task is to create one of the [Bell states](https://en.wikipedia.org/wiki/Bell_state) on them according to the _index_: ## Input You have to implement an operation which takes an array of 2 qubits and an integer as an input and has no output. The "output" of your solution is the state in which it left the input qubits. Your code should have the following signature: namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit\[\], index : Int) : () { body { // your code here } } } [samples]
给定两个处于状态 的量子比特和一个整数 #cf_span[index]。你的任务是根据 #cf_span[index] 在它们之上构造一个贝尔态: 你需要实现一个操作,该操作以包含 2 个量子比特的数组和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后输入量子比特所处的状态。 你的代码应具有以下签名: ## Input 你需要实现一个操作,该操作以包含 2 个量子比特的数组和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后输入量子比特所处的状态。你的代码应具有以下签名:namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit[], index : Int) : () { body { // your code here } }} [samples]
**Definitions** Let $ \mathcal{H} = \mathbb{C}^2 \otimes \mathbb{C}^2 $ be the Hilbert space of two qubits. Let $ \{ |0\rangle, |1\rangle \} $ be the computational basis for a single qubit. Let $ \{ |\Phi^+\rangle, |\Phi^-\rangle, |\Psi^+\rangle, |\Psi^-\rangle \} $ denote the four Bell states: $$ \begin{aligned} |\Phi^+\rangle &= \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle), \\ |\Phi^-\rangle &= \frac{1}{\sqrt{2}}(|00\rangle - |11\rangle), \\ |\Psi^+\rangle &= \frac{1}{\sqrt{2}}(|01\rangle + |10\rangle), \\ |\Psi^-\rangle &= \frac{1}{\sqrt{2}}(|01\rangle - |10\rangle). \end{aligned} $$ Let $ c \in \{0, 1, 2, 3\} $ be an integer index specifying the target Bell state. **Constraints** 1. The input is a two-qubit system in an arbitrary initial state $ |\psi\rangle \in \mathcal{H} $. 2. The index $ c $ satisfies $ 0 \leq c \leq 3 $. 3. The operation is unitary and acts only on the two input qubits. 4. The operation has no classical output; the result is the final quantum state of the system. **Objective** Implement a unitary operation $ U_c $ such that, for any initial state $ |\psi\rangle $, the transformation $$ U_c |\psi\rangle = |\text{Bell}_c\rangle $$ is **not** required — instead, the operation must map the *standard initial state* $ |00\rangle $ to the Bell state $ |\text{Bell}_c\rangle $: $$ U_c |00\rangle = |\text{Bell}_c\rangle, $$ where $ |\text{Bell}_c\rangle $ is defined by: $$ |\text{Bell}_c\rangle = \begin{cases} |\Phi^+\rangle & \text{if } c = 0, \\ |\Phi^-\rangle & \text{if } c = 1, \\ |\Psi^+\rangle & \text{if } c = 2, \\ |\Psi^-\rangle & \text{if } c = 3. \end{cases} $$
API Response (JSON)
{
  "problem": {
    "name": "B. Generate Bell state",
    "description": {
      "content": "You are given two qubits in state and an integer _index_. Your task is to create one of the [Bell states](https://en.wikipedia.org/wiki/Bell_state) on them according to the _index_:",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1001B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given two qubits in state and an integer _index_. Your task is to create one of the [Bell states](https://en.wikipedia.org/wiki/Bell_state) on them according to the _index_:\n\n## Input\n\nYou hav...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定两个处于状态  的量子比特和一个整数 #cf_span[index]。你的任务是根据 #cf_span[index] 在它们之上构造一个贝尔态:\n\n你需要实现一个操作,该操作以包含 2 个量子比特的数组和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后输入量子比特所处的状态。\n\n你的代码应具有以下签名:\n\n## Input\n\n你需要实现一个操作,该操作以包含 2 个量子比特的数组和...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ \\mathcal{H} = \\mathbb{C}^2 \\otimes \\mathbb{C}^2 $ be the Hilbert space of two qubits.  \nLet $ \\{ |0\\rangle, |1\\rangle \\} $ be the computational basis for a single qubit.  \nLet ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments