3 3 2 -1 1
6 There are three possible sequences $B'$: $(2,1,1)$, $(2,2,1)$, and $(2,3,1)$. When $B' = (2,1,1)$, an edge is drawn only between vertices $2$ and $3$, so the number of connected components is $2$. Thus, $f(B') = 2$. Similarly, $f(B') = 2$ for $B' = (2,2,1)$ and $f(B') = 2$ for $B' = (2,3,1)$, so the answer is $2 + 2 + 2 = 6$.
10 8 -1 7 -1 -1 -1 2 -1 1 -1 2
329785
11 12 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
529513150 Remember to find the sum modulo $998244353$.
{
"problem": {
"name": "Sum of CC",
"description": {
"content": "For a sequence $A = (A_1, \\ldots, A_N)$ of length $N$, define $f(A)$ as follows. * Prepare a graph with $N$ vertices labeled $1$ to $N$ and zero edges. For every integer pair $(i, j)$ satisfying $1",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc187_b"
},
"statements": [
{
"statement_type": "Markdown",
"content": "For a sequence $A = (A_1, \\ldots, A_N)$ of length $N$, define $f(A)$ as follows.\n\n* Prepare a graph with $N$ vertices labeled $1$ to $N$ and zero edges. For every integer pair $(i, j)$ satisfying $1...",
"is_translate": false,
"language": "English"
}
]
}