Tasks:
 
Task DescriptionDiscussion (0)
Task :: Kraljevi
Mirko and Slavko are playing a chess like game. The game is played on a
non-standard chess board sized R rows by C columns. Each player starts with some number of chess kings. In chess kings can move from their current field
to any of the 8 neighbouring fields.Player spread is defined as the complete sum of distances between all pairs of pieces of the given player. The distance between two pieces is the smallest number of moves required for both pieces to reach the same field.No actual moves are performed when calculating the distance and as such enemy pieces do not influence the result.Mirko knows that the spread is a vital piece of strategic information and would like you to make him a program that will calculate both his and Slavko's spread.

INPUT:
The first line of input contains two integers R and C (1 ≤ R, C ≤ 1 000),number of rows and columns.Next R lines contain C characters each. Character 'M' denotes Mirko's piece,'S' Slavko's piece and '.' denotes an empty field.There is at least one piece per player on the board. Otherwise the game
would be over.

OUTPUT:
In the first and only line of output you need to print exactly two integers. The
first integers is the spread of Mirko's and the second Slavko's pieces.

Input:
2 3
SMS
MMS

Output:
3 5
Submit Solution
:
:
Available Languages
Task info
Name:Kraljevi
Time:3 sec.
Memory:64 MB
#Tests:10
AddedBy: dario-dsa
Source:COCI 2009/10
Task Ratings
Difficulty:

5 (4 votes)
Quality:

5 (4 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
budabudimir 0.945 s.
Amtrix 1.185 s.
D.Ostojic 1.71 s.
thepsint 1.77 s.
msantl 2.655 s.
gates 2.715 s.
Dgleich 3.705 s.
mbalunovic 3.87 s.
simpleton 4.62 s.
Solved By