J. Junction of Orz Pandas

Codeforces
IDCF10287J
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
The Orz Pandas are building a electric power grid. There are $n$ vertical power lines and $m$ horizontal power lines. To make the power grid stable, the Orz Pandas should build one junction between each vertical power line and each horizontal power line. There should be $n times m$ junctions. Each junction has a design parameter. Let's use $p_{i j}$ to denote the design parameter of the junction between the $i$-th vertical power line and the $j$-th horizontal power line. To ensure the safety of the power grid, it must satisfies the following conditions: Now the Orz Panda engineers have already calculated $a_i$ and $b_j$ for each power line. It's very easy to output a possible solution of $p_{i j}$ satisifying those conditions, or report they can't be satisified. To make the problem more challenging, the Orz Pandas want you to output the number of different solutions satisifying those conditions. Two solutions $p$ and $q$ are considered different if and only if there exists a pair $(i, j)$, such that $p_{i j} eq.not q_{i j}$. Since the answer may be very large, you should output it modulo $998244353$. There is only one test case in the input file. The first line contains two integers $n$ and $m$. The second line contains $n$ integers $a_1, a_2, \\\\cdots, a_n$. The third line contains $m$ integers $b_1, b_2, \\\\cdots, b_n$. It's guaranteed that $1 <= n, m <= 10^5$, and $1 <= a_i, b_i <= 10^9$. Output one line containing the number of different answers, modulo $998244353$. For the sample, the possible solutions are: $$ \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 1 \\ \hline 1 & 1 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 2 \\ \hline 1 & 1 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 1 \\ \hline 1 & 2 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 2 \\ \hline 1 & 2 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 1 & 2 \\ \hline 1 & 2 & 3 \\ \hline \end{array} $$ ## Input There is only one test case in the input file.The first line contains two integers $n$ and $m$.The second line contains $n$ integers $a_1, a_2, \\\\cdots, a_n$.The third line contains $m$ integers $b_1, b_2, \\\\cdots, b_n$.It's guaranteed that $1 <= n, m <= 10^5$, and $1 <= a_i, b_i <= 10^9$. ## Output Output one line containing the number of different answers, modulo $998244353$. [samples] ## Note For the sample, the possible solutions are:$$ \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 1 \\ \hline 1 & 1 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 2 \\ \hline 1 & 1 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 1 \\ \hline 1 & 2 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 2 & 2 \\ \hline 1 & 2 & 3 \\ \hline \end{array} \quad \begin{array}{|c|c|c|} \hline 1 & 1 & 1 \\ \hline 1 & 1 & 2 \\ \hline 1 & 2 & 3 \\ \hline \end{array} $$
**Definitions** Let $ F(x) = a_4 x^4 + a_3 x^3 + a_2 x^2 + a_1 x + a_0 $ be a quartic polynomial with integer coefficients $ a_i \in [-100, 100] $ for $ i = 0, 1, 2, 3, 4 $. Let $ \mathbf{f} = (f_1, f_2, f_3, f_4, f_5) \in \mathbb{Z}^5 $ be a given sequence of observed values. **Constraints** For each $ i \in \{1, 2, 3, 4, 5\} $: $$ |F(i) - f_i| \leq 1 $$ **Objective** Given $ \mathbf{f} $, find the unique (or any one) tuple $ (a_0, a_1, a_2, a_3, a_4) \in \mathbb{Z}^5 $ satisfying the above constraints.
API Response (JSON)
{
  "problem": {
    "name": "J. Junction of Orz Pandas",
    "description": {
      "content": "The Orz Pandas are building a electric power grid. There are $n$ vertical power lines and $m$ horizontal power lines. To make the power grid stable, the Orz Pandas should build one junction between ea",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10287J"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The Orz Pandas are building a electric power grid. There are $n$ vertical power lines and $m$ horizontal power lines. To make the power grid stable, the Orz Pandas should build one junction between ea...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ F(x) = a_4 x^4 + a_3 x^3 + a_2 x^2 + a_1 x + a_0 $ be a quartic polynomial with integer coefficients $ a_i \\in [-100, 100] $ for $ i = 0, 1, 2, 3, 4 $.  \nLet $ \\mathbf{f} = (f_...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments