A3. Generate superposition of two basis states

Codeforces
IDCF1002A3
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . You are also given two bitstrings _bits_0 and _bits_1 which describe two different basis states on _N_ qubits and . Your task is to generate a state which is an equal superposition of the given basis states: You have to implement an operation which takes the following inputs: * an array of qubits _qs_, * two arrays of Boolean values _bits_0 and _bits_1 representing the basis states and . These arrays will have the same length as the array of qubits. _bits_0 and _bits_1 will differ in at least one position. The operation doesn't have an output; its "output" is the state in which it leaves the qubits. Your code should have the following signature: namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit\[\], bits0 : Bool\[\], bits1 : Bool\[\]) : () { body { // your code here } } } [samples]
给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),初始处于零态。同时给定两个比特串 #cf_span[bits0] 和 #cf_span[bits1],它们描述了 #cf_span[N] 个量子比特上的两个不同基态。 你的任务是生成一个状态,该状态是给定基态的等权重叠加: 你需要实现一个操作,它接受以下输入: 该操作没有输出;其“输出”是操作完成后量子比特所处的状态。 你的代码应具有以下签名: [samples]
**Definitions** Let $ N \in \mathbb{Z} $ with $ 1 \leq N \leq 8 $. Let $ |b_0\rangle, |b_1\rangle \in \{0,1\}^N $ be two distinct computational basis states on $ N $ qubits. **Given** The initial state of the system is $ |0\rangle^{\otimes N} $. **Objective** Implement a unitary operation that transforms the initial state into: $$ \frac{1}{\sqrt{2}} \left( |b_0\rangle + |b_1\rangle \right) $$ **Constraints** - $ |b_0\rangle \neq |b_1\rangle $ - The operation must be implemented using quantum gates on $ N $ qubits. - No measurement is permitted; the output is the final quantum state.
API Response (JSON)
{
  "problem": {
    "name": "A3. Generate superposition of two basis states",
    "description": {
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . You are also given two bitstrings _bits_0 and _bits_1 which describe two different basis states on _N_ qubits and . Your task is to generate a 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": "CF1002A3"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . You are also given two bitstrings _bits_0 and _bits_1 which describe two different basis states on _N_ qubits and .\n\nYour task is to generate a s...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),初始处于零态。同时给定两个比特串 #cf_span[bits0] 和 #cf_span[bits1],它们描述了 #cf_span[N] 个量子比特上的两个不同基态。\n\n你的任务是生成一个状态,该状态是给定基态的等权重叠加:\n\n你需要实现一个操作,它接受以下输入:\n\n该操作没有输出;其“输出”是操作完成后量子比特所...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z} $ with $ 1 \\leq N \\leq 8 $.  \nLet $ |b_0\\rangle, |b_1\\rangle \\in \\{0,1\\}^N $ be two distinct computational basis states on $ N $ qubits.  \n\n**Given**  \nThe ini...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments