デンソークリエイトプログラミングコンテスト2023(AtCoder Beginner Contest 309)
翻译中…
Problem Statement
翻译中…
We have a grid with $N$ rows and $M$ columns. We denote by $(i,j)$ the cell in the $i$-th row from the top and $j$-th column from the left.
翻译中…
You are given integer sequences $A=(A_1,A_2,\dots,A_K)$ and $B=(B_1,B_2,\dots,B_L)$ of lengths $K$ and $L$, respectively.
翻译中…
Find the sum, modulo $998244353$, of the answers to the following question over all integer pairs $(i,j)$ such that $1 \le i \le K$ and $1 \le j \le L$.
翻译中…
- A piece is initially placed at
$(1,A_i)$. How many paths are there to take it to$(N,B_j)$by repeating the following move$(N-1)$times? - Let
$(p,q)$be the piece's current cell. Move it to$(p+1,q-1),(p+1,q)$, or$(p+1,q+1)$, without moving it outside the grid.
翻译中…
Constraints
翻译中…
$1 \le N \le 10^9$$1 \le M,K,L \le 10^5$$1 \le A_i,B_j \le M$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N M K L
A_1 A_2 \dots A_K
B_1 B_2 \dots B_L
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3 4 1 2
1
1 2
Output #1
4
For $(i,j)=(1,1)$, the following two paths are possible:
- $(1,1) \rightarrow (2,1) \rightarrow (3,1)$
- $(1,1) \rightarrow (2,2) \rightarrow (3,1)$
For $(i,j)=(1,2)$, the following two paths are possible:
- $(1,1) \rightarrow (2,1) \rightarrow (3,2)$
- $(1,1) \rightarrow (2,2) \rightarrow (3,2)$
Thus, the answer is $2 + 2 =4$.
Input #2
5 8 4 5
3 1 4 1
2 7 1 8 2
Output #2
137
Input #3
883671387 87719 10 12
86879 64174 47274 41688 17713 50897 53989 7210 30894 5714
60358 28835 48036 48450 67149 36558 35929 69025 77539 19195 60762 60721
Output #3
941873621
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。