B1. Distinguish zero state and W state

Codeforces
IDCF1002B1
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given _N_ qubits (2 ≤ _N_ ≤ 8) which are guaranteed to be in one of the two states: * state, or * state.Your task is to perform necessary operations and measurements to figure out which state it was and to return 0 if it was state or 1 if it was W state. The state of the qubits after the operations does not matter. You have to implement an operation which takes an array of _N_ qubits 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 (qs : Qubit\[\]) : Int { body { // your code here } } } [samples]
给定 #cf_span[N] 个量子比特(#cf_span[2 ≤ N ≤ 8]),它们保证处于以下两种状态之一: 你的任务是执行必要的操作和测量,以确定其处于哪种状态,并在是 $|0\dots0\rangle$ 态时返回 0,在是 $|W\rangle$ 态时返回 1。操作后量子比特的状态无关紧要。 你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,并返回一个整数。 你的代码应具有以下签名: [samples]
**Definitions** Let $ N \in \mathbb{Z} $ with $ 2 \leq N \leq 8 $. Let $ \mathcal{H} = (\mathbb{C}^2)^{\otimes N} $ be the Hilbert space of $ N $ qubits. Let $ |\psi_0\rangle = |0\rangle^{\otimes N} $ denote the $ |0\rangle^{\otimes N} $ state. Let $ |\psi_1\rangle = |W_N\rangle = \frac{1}{\sqrt{N}} \sum_{i=1}^N |0\rangle^{\otimes (i-1)} |1\rangle |0\rangle^{\otimes (N-i)} $ denote the $ N $-qubit W state. The input qubit register is guaranteed to be in one of the two states: $ |\psi_0\rangle $ or $ |\psi_1\rangle $. **Objective** Implement a quantum operation that, given an $ N $-qubit register in either $ |\psi_0\rangle $ or $ |\psi_1\rangle $, outputs: $$ \begin{cases} 0 & \text{if the state is } |\psi_0\rangle \\ 1 & \text{if the state is } |\psi_1\rangle \end{cases} $$ The output is obtained via measurement(s) and classical post-processing. The final state of the qubits after the operation is irrelevant.
API Response (JSON)
{
  "problem": {
    "name": "B1. Distinguish zero state and W state",
    "description": {
      "content": "You are given _N_ qubits (2 ≤ _N_ ≤ 8) which are guaranteed to be in one of the two states: *   state, or *   state.Your task is to perform necessary operations and measurements to figure out which s",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1002B1"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given _N_ qubits (2 ≤ _N_ ≤ 8) which are guaranteed to be in one of the two states:\n\n*   state, or\n*   state.Your task is to perform necessary operations and measurements to figure out which s...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定 #cf_span[N] 个量子比特(#cf_span[2 ≤ N ≤ 8]),它们保证处于以下两种状态之一:\n\n你的任务是执行必要的操作和测量,以确定其处于哪种状态,并在是 $|0\\dots0\\rangle$ 态时返回 0,在是 $|W\\rangle$ 态时返回 1。操作后量子比特的状态无关紧要。\n\n你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,并返...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z} $ with $ 2 \\leq N \\leq 8 $.  \nLet $ \\mathcal{H} = (\\mathbb{C}^2)^{\\otimes N} $ be the Hilbert space of $ N $ qubits.  \nLet $ |\\psi_0\\rangle = |0\\rangle^{\\otime...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments