C. Generate GHZ state

Codeforces
IDCF1001C
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . Your task is to create Greenberger–Horne–Zeilinger (GHZ) state on them: Note that for _N_ = 1 and _N_ = 2 GHZ state becomes states and from the previous tasks, respectively. ## Input You have to implement an operation which takes an array of _N_ qubits 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\[\]) : () { body { // your code here } } } [samples]
给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),它们均处于零态。你的任务是为它们构造一个 Greenberger–Horne–Zeilinger(GHZ)态: 注意,当 #cf_span[N = 1] 和 #cf_span[N = 2] 时,GHZ 态分别变为前两道题中的态 和 。 你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。你的解法的“输出”是其作用后输入量子比特所处的状态。 你的代码应具有以下签名: ## Input 你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。你的解法的“输出”是其作用后输入量子比特所处的状态。你的代码应具有以下签名:namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit[]) : () { body { // your code here } }} [samples]
**Definitions** Let $ N \in \mathbb{Z} $ with $ 1 \leq N \leq 8 $. Let $ \mathcal{H} = (\mathbb{C}^2)^{\otimes N} $ be the Hilbert space of $ N $ qubits. Let $ |0\rangle^{\otimes N} $ denote the initial state of $ N $ qubits, all in the computational basis state $ |0\rangle $. **Objective** Implement a unitary operation $ U $ such that: $$ U |0\rangle^{\otimes N} = \frac{1}{\sqrt{2}} \left( |0\rangle^{\otimes N} + |1\rangle^{\otimes N} \right) $$ This is the $ N $-qubit Greenberger–Horne–Zeilinger (GHZ) state. **Constraints** - The operation must act on exactly $ N $ qubits. - The operation must be implemented using quantum gates (no classical post-processing or measurement-based state preparation). - The operation has no output; the final state of the qubits is the result.
API Response (JSON)
{
  "problem": {
    "name": "C. Generate GHZ state",
    "description": {
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . Your task is to create Greenberger–Horne–Zeilinger (GHZ) state on them: Note that for _N_ = 1 and _N_ = 2 GHZ state becomes states and from the ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1001C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . Your task is to create Greenberger–Horne–Zeilinger (GHZ) state on them:\n\nNote that for _N_ = 1 and _N_ = 2 GHZ state becomes states and from the ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),它们均处于零态。你的任务是为它们构造一个 Greenberger–Horne–Zeilinger(GHZ)态:\n\n注意,当 #cf_span[N = 1] 和 #cf_span[N = 2] 时,GHZ 态分别变为前两道题中的态  和  。\n\n你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z} $ with $ 1 \\leq N \\leq 8 $.  \nLet $ \\mathcal{H} = (\\mathbb{C}^2)^{\\otimes N} $ be the Hilbert space of $ N $ qubits.  \nLet $ |0\\rangle^{\\otimes N} $ denote the...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments