RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00149

Kraljevi

Platinum IV 플래티넘 IV
난이도
1s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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 king moves required to travel from one piece to the other, i.e. \(\max(|r_1 - r_2|,\ |c_1 - c_2|)\) for pieces on fields \((r_1, c_1)\) and \((r_2, c_2)\). 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.

제약

In test cases worth 20% of total points the number of pieces on the board
will be less then or equal to 5000.
In test cases worth 60% of total points, the numbers R and C will be smaller
than or equal to 300.
SAMPLE TEST CASES
Input:
2 3
SMS
MMS
Input:
2 3
S.M
M..
Input:
4 5
M....
..S.M
SS..S
.M...
Output:
3 5
Output:
2 0
Output:
10 13

입력 형식

The first line of input contains two integers \(R\) and \(C\) (\(1 \le R, C \le 1000\)), the number of rows and columns.

The 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.

출력 형식

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

Scoring: In test cases worth \(20\%\) of total points the number of pieces on the board will be less than or equal to \(5000\). In test cases worth \(60\%\) of total points, the numbers \(R\) and \(C\) will be smaller than or equal to \(300\).

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
2 3
SMS
MMS
출력
3 5
예제 2
입력
2 3
S.M
M..
출력
2 0
예제 3
입력
4 5
M....
..S.M
SS..S
.M...
출력
10 13
문제 정보

riseoj 작성

출처 COCI 2009/2010 Contest 7

평가 및 의견

Kraljevi

개요
출제자 난이도 Platinum IV 플래티넘 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Kraljevi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8