#P17528. [JAG 2026 Summer Camp #1] Neighbour or Opposite
[JAG 2026 Summer Camp #1] Neighbour or Opposite
Problem Description
There are seats arranged in a circle, numbered in clockwise order.
For each (), seats and are neighbours. Seats and are also neighbours.
For each (), seats and are opposite each other.
Some of the seats are occupied. For each (), seat is occupied by exactly one person if is o, and is empty if 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 ().
The second line contains a string of length 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 .
3
ooxoxx
1 2
2
oooo
2 3
4
xxxxxxxx
0 1