Codeforces Round 729 (Div. 2) |
---|
Finished |
You are given a sequence $$$A$$$, where its elements are either in the form + x or -, where $$$x$$$ is an integer.
For such a sequence $$$S$$$ where its elements are either in the form + x or -, define $$$f(S)$$$ as follows:
The sequence $$$b$$$ is a subsequence of the sequence $$$a$$$ if $$$b$$$ can be derived from $$$a$$$ by removing zero or more elements without changing the order of the remaining elements. For all $$$A$$$'s subsequences $$$B$$$, compute the sum of $$$f(B)$$$, modulo $$$998\,244\,353$$$.
The first line contains an integer $$$n$$$ ($$$1\leq n\leq 500$$$) — the length of $$$A$$$.
Each of the next $$$n$$$ lines begins with an operator + or -. If the operator is +, then it's followed by an integer $$$x$$$ ($$$1\le x<998\,244\,353$$$). The $$$i$$$-th line of those $$$n$$$ lines describes the $$$i$$$-th element in $$$A$$$.
Print one integer, which is the answer to the problem, modulo $$$998\,244\,353$$$.
4 - + 1 + 2 -
16
15 + 2432543 - + 4567886 + 65638788 - + 578943 - - + 62356680 - + 711111 - + 998244352 - -
750759115
In the first example, the following are all possible pairs of $$$B$$$ and $$$f(B)$$$:
The sum of these values is $$$16$$$.
Name |
---|