| Codeforces Round 1065 (Div. 3) |
|---|
| Finished |
Adachi is in the middle of a generational crashout... over, uh, this problem! Yep, that's definitely it... anyways, please help her solve it!
You are given two arrays $$$a$$$ and $$$b$$$ of length $$$n$$$ ($$$1\leq a_i\leq b_i$$$).
In one operation, you may either:
Let $$$x$$$ denote the minimum number of operations needed to make $$$a = b$$$. Two arrays $$$a$$$ and $$$b$$$ of length $$$n$$$ are considered equal if $$$a_i = b_i$$$ for all $$$1\leq i\leq n$$$.
Find the value of $$$x$$$. Additionally, count the number of sequences of operations that make $$$a = b$$$ using exactly $$$x$$$ operations. Two such sequences of operations are considered different if, for any $$$1\leq j\leq x$$$, the $$$j$$$-th operation of each sequence differs (either in the type of operation selected or the index chosen, if applicable).
Since the number of sequences may be large, output it modulo $$${\color{red}{10^6+3}}$$$. Note that $$$10^6+3$$$ is a prime number.
The first line contains a single integer $$$t$$$ ($$$1\leq t\leq 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2\leq n\leq 2\cdot 10^5$$$).
The second line of each test case contains $$$n$$$ integers, $$$a_1, a_2, \dots, a_n$$$ ($$$1\leq a_i\leq 10^6$$$).
The third line of each test case contains $$$n$$$ integers, $$$b_1, b_2, \dots, b_n$$$ ($$$a_i\leq b_i\leq 10^6$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output two integers, the value of $$$x$$$, and the number of sequences of operations that make $$$a = b$$$ using exactly $$$x$$$ operations, modulo $$$10^6+3$$$. The value of $$$x$$$ should be printed exactly; that is, it should not be taken modulo $$$10^6 + 3$$$.
861 3 6 4 3 23 7 10 4 4 821 14 352 3 2 5 118 13 10 30 755 4 3 6 2100 125 231 113 10742 2 2 22 2 2 241 1 1 12 2 2 271 1 1 1 1 1 200000200000 200000 200000 200000 200000 200000 2000003542264 174876 441510641112 325241 995342
17 8271163 112 28835 5678120 11 11199994 0803045 366998
In the second sample, it is possible to convert $$$a$$$ into $$$b$$$ using only three operations. There is only one way to do so, namely:
It can be shown that it is impossible to convert $$$a$$$ into $$$b$$$ using fewer than three operations.
| Name |
|---|


