B. Bin Packing

Codeforces
IDCF10282B
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Packing items into a bin is well known as packing problem, and Fish is studying it too. As a beginner, he starts with $2$-dimension-version problem with $2$ rectangle-shape items. He just wants to find a convex polygon with the smallest area so that these two items can be well included in it. You should notice that these two items can not overlap each other and you can shift or rotate them in the plane if you like. Please help Fish solve the problem. The first line of input contains an integer $T$, representing the number of test cases. Then following $T$ lines, each line representing one test case. For each test case there are four integers $w_1, h_1, w_2, h_2$ separated by one space telling the width and length of these two items respectively. For each test case, you should output *Case $x$: $y$* in one line, where $x$ indicates the case number starting from $1$ and $y$ represents the smallest area. Your answers will be consider correct if its absolute error does not exceed $10^(-6)$. $1 <= T <= 100$ $1 <= w_1, h_1, w_2, h_1 <= 100$ ## Input The first line of input contains an integer $T$, representing the number of test cases. Then following $T$ lines, each line representing one test case.For each test case there are four integers $w_1, h_1, w_2, h_2$ separated by one space telling the width and length of these two items respectively. ## Output For each test case, you should output *Case $x$: $y$* in one line, where $x$ indicates the case number starting from $1$ and $y$ represents the smallest area.Your answers will be consider correct if its absolute error does not exceed $10^(-6)$. [samples] ## Note $1 <= T <= 100$$1 <= w_1, h_1, w_2, h_1 <= 100$
**Definitions** Let $ n, m, k \in \mathbb{Z}^+ $. Let $ A = (a_1, a_2, \dots, a_{n+m}) \in \mathbb{Z}^{n+m} $ be the left-front view heights. Let $ C = \{ (x_i, y_i, h_i) \mid i \in \{1, \dots, k\} \} $ be the set of fixed block constraints, with $ x_i \in \{1, \dots, n\} $, $ y_i \in \{1, \dots, m\} $, $ h_i \in \mathbb{Z}^+ $. **Constraints** 1. For each $ j \in \{1, \dots, n+m\} $, the left-front view height $ a_j $ corresponds to the maximum height over a diagonal in the $ n \times m $ grid: - For $ j \in \{1, \dots, n\} $: $ a_j = \max_{i=1}^{j} b_{i, j-i+1} $ - For $ j \in \{n+1, \dots, n+m\} $: $ a_j = \max_{i=j-n}^{m} b_{i, j-i} $ (where $ b_{x,y} $ is the height at grid cell $ (x,y) $) 2. For each constraint $ (x_i, y_i, h_i) \in C $: $ b_{x_i, y_i} = h_i $ 3. $ b_{x,y} \in \mathbb{Z}^+ $ for all $ x \in \{1, \dots, n\}, y \in \{1, \dots, m\} $ 4. $ \sum_{i=1}^n n_i + \sum_{i=1}^m m_i + \sum_{i=1}^k k_i \leq 10^5 $, where $ n_i, m_i, k_i $ are the values in test cases (sum over all test cases) **Objective** Count the number of integer matrices $ B = (b_{x,y})_{n \times m} $ satisfying the above constraints, modulo $ 10^9 + 7 $.
API Response (JSON)
{
  "problem": {
    "name": "B. Bin Packing",
    "description": {
      "content": "Packing items into a bin is well known as packing problem, and Fish is studying it too. As a beginner, he starts with $2$-dimension-version problem with $2$ rectangle-shape items. He just wants to fin",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10282B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Packing items into a bin is well known as packing problem, and Fish is studying it too. As a beginner, he starts with $2$-dimension-version problem with $2$ rectangle-shape items. He just wants to fin...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, m, k \\in \\mathbb{Z}^+ $.  \nLet $ A = (a_1, a_2, \\dots, a_{n+m}) \\in \\mathbb{Z}^{n+m} $ be the left-front view heights.  \nLet $ C = \\{ (x_i, y_i, h_i) \\mid i \\in \\{1, \\dots, ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments