E. Subrect Query

Codeforces
IDCF10057E
Time8000ms
Memory512MB
Difficulty
English · Original
Formal · Original
De Prezer loves rectangles.He has a n × m rectangle which there is a number in each of its cells. We show the number in the j - th column of the i - th row by ai, j. De Prezer also loves query. So he gives you q queries. In each query, he gives you number k and asks you to print the number of subrectangles of this rectangle that the difference between the maximum element and the minimum element in them is at most k . The first line of input contains 3 integers, n, m and q . In the next n lines, there are informations of the rectangle. i - th line among them, contains m space separated integers, ai, 1, ai, 2, ..., ai, m . The next q lines, each line contains a single integer k (for that query). 1 ≤ n, m ≤ 400 1 ≤ q ≤ 10 1 ≤ ai, j ≤ 109 (for each 1 ≤ i ≤ n and 1 ≤ j ≤ m) 0 ≤ k ≤ 109 (for each query) For each query, print the answer in a single line. ## Input The first line of input contains 3 integers, n, m and q .In the next n lines, there are informations of the rectangle. i - th line among them, contains m space separated integers, ai, 1, ai, 2, ..., ai, m .The next q lines, each line contains a single integer k (for that query).1 ≤ n, m ≤ 4001 ≤ q ≤ 101 ≤ ai, j ≤ 109 (for each 1 ≤ i ≤ n and 1 ≤ j ≤ m)0 ≤ k ≤ 109 (for each query) ## Output For each query, print the answer in a single line. [samples]
Let $ n \in \mathbb{Z} $ with $ 1 \leq n \leq 10^5 $. Let $ n = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k} $ be the prime factorization of $ n $, where $ p_1 < p_2 < \cdots < p_k $ are distinct primes and $ e_i \geq 1 $. **Objective**: Compute $ \sum_{i=1}^k p_i $, the sum of the distinct prime factors of $ n $, and store it in the first storage.
API Response (JSON)
{
  "problem": {
    "name": "E. Subrect Query",
    "description": {
      "content": "De Prezer loves rectangles.He has a n × m rectangle which there is a number in each of its cells. We show the number in the j - th column of the i - th row by ai, j. De Prezer also loves query. So he",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 8000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10057E"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "De Prezer loves rectangles.He has a n × m rectangle which there is a number in each of its cells. We show the number in the j - th column of the i - th row by ai, j.\n\nDe Prezer also loves query. So he...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Let $ n \\in \\mathbb{Z} $ with $ 1 \\leq n \\leq 10^5 $.  \nLet $ n = p_1^{e_1} p_2^{e_2} \\cdots p_k^{e_k} $ be the prime factorization of $ n $, where $ p_1 < p_2 < \\cdots < p_k $ are distinct primes and...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments