Boardgame Expo
시간 제한2초메모리 제한2048 MB
친구 관계 그래프에서 각 구간이 연결 부분 그래프를 이루도록 줄을 최소 개수의 연속한 구간으로 나누고, 그 크기들을 출력한다.
문제
Every year, a big Boardgame Expo takes place in Cluj-Napoca, showcasing a wide selection of new games. The main attraction this year is a game called BoardOina.
There are players lined up in a queue, waiting to try out the game. Players are numbered from to in their order in the queue. Player is at the front of the queue and player is at the back.
There are distinct friendship relations between pairs of players in the queue. Specifically, for each from to , inclusive, player and player are friends, where . Friendship relations are symmetric.
Consider a sequence of consecutive players in the queue starting at player (for any and such that and ). This sequence of players forms a friend group of size if for all pairs of two players, they are connected by a sequence of friendship relations within that friend group. Specifically, players form a friend group of size if, for each and such that , there exists a sequence of players such that:
- ;
- for each from to , inclusive;
- and ;
- players and are friends for each from to , inclusive.
Note that in the case of , player alone forms a friend group of size .
BoardOina can be played by any number of players. However, to make the game more successful, the organizers only let friend groups play it.
Only one group can play at a time. For each game, a friend group starting at the player at the front of the queue is formed, and starts playing the game. The players in this friend group are removed from the queue. This process is repeated until the queue becomes empty. Formally, we say that the queue can be partitioned into friend groups if there exists an array of group sizes, , such that each of the following conditions holds.
- and (for each such that );
- ;
- for each between and , inclusive, players form a friend group of size , where and otherwise .
The organizers want to minimize the number of friend groups that play the game. That is, they want to partition the queue into friend groups such that it is not possible to partition the queue into (or less) friend groups.
Your task is to find a partitioning of the queue into a minimum number of friend groups, and report the array of group sizes.
제한
- (for each such that )
- Friendship relations are distinct. In other words, or (for each and such that ).
- If there are multiple solutions with minimum number of groups, you can return any valid solution.
예제
이 문제는 공개된 예제가 없습니다.