E. Rikka with Data Structures

Codeforces
IDCF10201E
Time10000ms
Memory1024MB
Difficulty
English · Original
Formal · Original
As we know, Rikka is poor at data structures. Yuta is worrying about this situation, so he gives Rikka some tasks about data structures to practice. Here is one of them: Yuta has an array $A$ with $n$ numbers, denoted by $A [ 1 ], A [ 2 ], \\\\cdots, A [ n ]$. Then he makes $m$ operations on it. There are three types of operations: It is too difficult for Rikka. Can you help her? The input contains several test cases, and the first line contains a single integer $T$ ($1 <= T <= 200$), the number of test cases. For each test case, the first line contains two integers $n$ ($1 <= n <= 10^5$) and $m$ ($1 <= m <= 10^5$). The second line contains $n$ integers $A [ 1 ], A [ 2 ], \\\\cdots, A [ n ]$ ($1 <= A [ i ] <= 10^9$). Then $m$ lines follow, each line of which describes an operation, containing four integers as mentioned above, satisfying $1 <= l <= r <= n$, $1 <= k <= 10^9$ and $1 <= x <= n$. The input guarantees that there are at most $10$ test cases with $n > 10^3$ or $m > 10^3$. For each query, an operation of type $3$, output a single line with a single integer, the answer to this query. ## Input The input contains several test cases, and the first line contains a single integer $T$ ($1 <= T <= 200$), the number of test cases.For each test case, the first line contains two integers $n$ ($1 <= n <= 10^5$) and $m$ ($1 <= m <= 10^5$).The second line contains $n$ integers $A [ 1 ], A [ 2 ], \\\\cdots, A [ n ]$ ($1 <= A [ i ] <= 10^9$).Then $m$ lines follow, each line of which describes an operation, containing four integers as mentioned above, satisfying $1 <= l <= r <= n$, $1 <= k <= 10^9$ and $1 <= x <= n$.The input guarantees that there are at most $10$ test cases with $n > 10^3$ or $m > 10^3$. ## Output For each query, an operation of type $3$, output a single line with a single integer, the answer to this query. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case: - Let $ n, m \in \mathbb{Z} $ denote the length of array $ A $ and number of operations. - Let $ A = (A[1], A[2], \dots, A[n]) $ be the initial array of integers. - Let $ \mathcal{O} = (O_1, O_2, \dots, O_m) $ be a sequence of $ m $ operations, each of type $ 1 $, $ 2 $, or $ 3 $, specified by four integers: **Operations** For each operation $ O_j $: - **Type 1**: $ (1, l, r, k) $: For all $ i \in [l, r] $, set $ A[i] \gets A[i] + k $. - **Type 2**: $ (2, l, r, k) $: For all $ i \in [l, r] $, set $ A[i] \gets k $. - **Type 3**: $ (3, l, r, x) $: Query the number of indices $ i \in [l, r] $ such that $ A[i] = x $. **Constraints** 1. $ 1 \le T \le 200 $ 2. For each test case: - $ 1 \le n \le 10^5 $, $ 1 \le m \le 10^5 $ - $ 1 \le A[i] \le 10^9 $ for all $ i \in \{1, \dots, n\} $ - For each operation: $ 1 \le l \le r \le n $, $ 1 \le k \le 10^9 $, $ 1 \le x \le n $ 3. At most 10 test cases have $ n > 10^3 $ or $ m > 10^3 $ **Objective** For each operation of type $ 3 $, output the count: $$ \left| \left\{ i \in [l, r] \mid A[i] = x \right\} \right| $$
API Response (JSON)
{
  "problem": {
    "name": "E. Rikka with Data Structures",
    "description": {
      "content": "As we know, Rikka is poor at data structures. Yuta is worrying about this situation, so he gives Rikka some tasks about data structures to practice. Here is one of them: Yuta has an array $A$ with $n",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 10000,
      "memory_limit": 1048576
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10201E"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "As we know, Rikka is poor at data structures. Yuta is worrying about this situation, so he gives Rikka some tasks about data structures to practice. Here is one of them:\n\nYuta has an array $A$ with $n...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ n, m \\in \\mathbb{Z} $ denote the length of array $ A $ and number of operations.  \n- Let $ A = (...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments