Calgary Collegiate Programming Competition 2019


2019-03-09 11:00 AKST

Calgary Collegiate Programming Competition 2019


2019-03-09 15:00 AKST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -590 days 21:15:14

Time elapsed


Time remaining


Problem F

Pubnite is an epic battle royale game featuring unique gameplay mechanics such as dancing! Every player enjoys dancing in the middle of fierce and brutal tactical firefights.

This unique feature has made Pubnite the second most popular game on the internet, next to none but BeeLizard’s first person shooter game OvalWatch! Epig Games, the developer of Pubnite, is thinking of pulling one last trick to outsell OverWatch, and defeat its competitor, BeeLizard, once and for all.

Announcing Epig Games’s new limited-time global event: Epig Dance Off!

In Epig Dance Off, players can invent dance moves, videotape themselves dancing and submit their dance moves to Epig Games, where Epig Games will rate the moves. At the end of the event, Epig Games will announce the moves with the best ratings, and incorporate those dance moves into the game. The inventors of the moves will be crowned Supreme Winners of Epig Dance Off, and there is no greater glory than that.

Epig Games ran into an issue. Too many players are eager to join the Epig Dance Off and there are too many submissions to rate. The incredibly smart designers at Epig Games came up with yet another ingenious idea – they shall use software to determine the rating of a dance!

Having not enough engineering power at Epig Games, they have hired an intern – you – to write software that rates a dance!

The rating system is designed as follows: Each dance is composed of a sequence of moves. The rating of the dance is the number of moves performed in the sequence.

The dance is described by a grid with $N$ rows and $M$ columns. Each character in the grid is either a ‘$’, denoting the dancer is seen in this position, or a ‘_’, denoting the dancer is not seen in this position. When there is a single blank column, that denotes a frame is completed and the dancer has completed one move, where a blank column is defined to contain only ‘_’.


The first line contains two integers $N$ and $M$. It is guaranteed that $1\leq N, M\leq 2\, 000$.

The next $N$ lines contains $M$ characters each. It is guaranteed that each character is either ‘_’or ‘$’. It is also guaranteed that both the first and last columns are non-blank, and no two consecutive columns are both blank.


Output a single integer $T$, the rating of the dance, i.e. number of dance moves in the recording.

Sample Input 1 Sample Output 1
13 50
Sample Input 2 Sample Output 2
2 2