#P15554. [CCPC 2025 哈尔滨站] Many Many Sequence Covering Problems
[CCPC 2025 哈尔滨站] Many Many Sequence Covering Problems
Problem Description
Consider the following two problems:
:
In this problem, you are given three non-negative integer sequences of length at the beginning. Each time, you may choose an interval with cost , such that the minimum of is not , and then decrease all of by . The goal is to make all numbers in become with the minimum total cost.
:
Based on Sequence Covering Problems, you are additionally given two non-negative integer sequences . Now you may perform the following operations any number of times: choose , pay cost to increase by , or pay cost to increase by . After all operations are finished, solve the Sequence Covering Problems for the modified sequences . Let the answer of that problem be , and let the total cost spent on the operations be . You need to maximize . If this value can be unbounded (infinite), output . Otherwise, output this maximum value.
Now you need to solve :
You are given five incomplete sequences of length . It is defined that if , then the value of is fixed as given; otherwise, the value of can be any integer in . The same rule applies to sequences .
You need to compute, over all possible completions, the sum of the corresponding answers of Many Sequence Covering Problems. Since the answer may be , you need to output separately: the sum of all answers (modulo ) over the cases where the answer is not , and the number of cases whose answer is . Since the results may be large, take all outputs modulo .
Input Format
The first line contains an integer (), indicating the length of the sequences.
The second line contains integers ().
The third line contains integers ().
The fourth line contains integers ().
The fifth line contains integers ().
The sixth line contains integers ().
Output Format
Output a single line containing two integers: the sum of all answers (modulo ) over the cases where the answer is not , and the number of cases where the answer is (modulo ).
2
1 1
1 2
2 1
-1 -1
-1 -1
8 12
3
-1 -2 2
1 3 0
-3 0 -2
1 -3 0
1 3 3
408 228
Hint
Translated by ChatGPT 5