33OJ
登录 注册

#P17528. [JAG 2026 Summer Camp #1] Neighbour or Opposite

[JAG 2026 Summer Camp #1] Neighbour or Opposite

Problem Description

There are 2N2N seats arranged in a circle, numbered 1,2,…,2N1,2,\ldots,2N in clockwise order.

For each ii (1≤i≤2N−11\le i\le 2N-1), seats ii and i+1i+1 are neighbours. Seats 11 and 2N2N are also neighbours.

For each ii (1≤i≤N1\le i\le N), seats ii and i+Ni+N are opposite each other.

Some of the seats are occupied. For each ii (1≤i≤2N1\le i\le 2N), seat ii is occupied by exactly one person if SiS_i is o, and is empty if SiS_i is x.

You want to form pairs of people subject to the following conditions.

  • Each person belongs to at most one pair.
  • Each pair consists of two people seated in neighbouring or opposite seats.

Find the maximum possible number of pairs and the number of ways to achieve this maximum.

Two ways of forming pairs are considered different if their sets of unordered pairs differ.

Input Format

The input consists of a single test case of the following format.

N
S

The first line contains an integer NN (1≤N≤1061\le N\le 10^6).

The second line contains a string SS of length 2N2N consisting of o and x.

Output Format

Print two integers separated by a space.

The first integer is the maximum possible number of pairs.

The second integer is the number of ways to achieve this maximum, modulo 998 244 353998\,244\,353.

3
ooxoxx
1 2
2
oooo
2 3
4
xxxxxxxx
0 1