| GPL 2026 Advanced |
|---|
| Закончено |
Boxuan is an aspiring K-Pop star planning her concerts in California. The state can be thought of as a forest of $$$N$$$ cities with $$$M$$$ $$$(0\leq M\leq N-1)$$$ roads between them. A forest is a collection of one or more disconnected components that are tree graphs.
Each city has fans, who are either $$$\color{red}{\text{excited}}$$$ or $$$\color{blue}{\text{tired}}$$$ of her singing.
When Boxuan performs in a city $$$v$$$, word travels and influences only the cities neighboring $$$v$$$.
The residents of city $$$v$$$ are not affected, as they are boycotting her concert over noise pollution concerns.
Boxuan knows the binary state of her fans at each city today, and which ones need to be excited / tired by the end of her tour.
A tour is defined as a set of cities, for each of which Boxuan performs a concert exactly once. Tours $$$A$$$ and $$$B$$$ are distinct iff Boxuan visits a city in tour $$$A$$$ but not in tour $$$B$$$, or Boxuan visits a city in tour $$$B$$$ but not in tour $$$A$$$. The tour may be empty.
Count the number of tours that can get her from the state now to her goal. This count can be large, so report it modulo $$$998\,244\,353$$$, or $$$0$$$ if no such tour can do so.
First line contains two integers $$$N$$$ and $$$M$$$, $$$1 \leq N \leq 2 \cdot 10^5$$$ and $$$0 \leq M \leq N-1$$$.
Second and third lines have respectively binary strings $$$s$$$ and $$$t$$$, which are both binary strings of length $$$N$$$.
$$$s_i = 1$$$ if the fans in city $$$i$$$ are excited today and $$$0$$$ if they are tired; $$$t_i$$$ says the same for how they must feel once the tour is over. Next $$$M$$$ lines have $$$u_i, v_i$$$ indicating an edge between $$$u_i$$$ and $$$v_i$$$, with $$$1 \leq u_i, v_i \leq N$$$ and $$$u_i \neq v_i$$$.
One integer, the number of unique concert tours Boxuan can take to reach her goal, modulo $$$998\,244\,353$$$, or $$$0$$$ if none are possible.
4 3000011111 21 31 4
4
3 20000011 22 3
0
3 10000101 2
2
5 400000011001 21 32 43 5
2
In the first sample the four tours are $$$\{1, 2\}$$$, $$$\{1, 3\}$$$, $$$\{1, 4\}$$$, and $$$\{1, 2, 3, 4\}$$$.
In the second sample, no tour works.
In the third sample, the two tours are $$$\{1\}$$$ and $$$\{1, 3\}$$$.
In the fourth sample, the two tours are $$$\{1\}$$$ and $$$\{4, 5\}$$$: performing in city $$$1$$$ excites both neighbors $$$2$$$ and $$$3$$$ at once, while performing in cities $$$4$$$ and $$$5$$$ excites them one each.
| Название |
|---|


