시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 632 369 303 64.744%

문제

Mickey의 뒷마당에는 특정 수의 양이 있다. 그가 단단히 잠든 사이에 배고픈 늑대는 마당에 들어와 양을 공격했다.

마당은 정사각형 모양에 행과 열로 이루어진 필드이다. 글자 '.' (점)은 빈 필드를 의미하며, 글자 '#'는 펜스를, 글자 'o'는 양, 'v'는 늑대를 의미한다.

우리는 수평, 수직으로만 이루어지고 펜스가 없는 경로에 한하여 한 필드에서 다른 필드로 이동할 수 있다면 같은 영역이라고 간주한다. 우리가 "탈출"할 수 있는 영역은 그 어떠한 영역의 부분으로도 간주하지 않는다.

다행히 우리의 양은 카라테 검은 띠 보유자여서 늑대에게 싸움을 걸 수 있고 영역에 늑대의 수보다 많다면 이기게 된다. 그렇지 않다면 그 지역 안의 모든 양을 먹는다.

맨 처음 모든 양과 늑대는 마당 안 영역에 존재한다.

아침이 도달했을 때 아직 살아남은 양과 늑대의 수를 출력하는 프로그램을 작성하라.

입력

첫 줄에는 두 정수 R과 C가 주어지며(3 ≤ R, C ≤ 250), 각 수는 마당의 행과 열의 수를 의미한다.

R개의 줄은 C개의 글자를 가진다. 이들 모두는 마당의 구조(마당의 펜스, 양, 늑대의 위치)를 의미한다.

참고: 50%의 입력은 간단한 구조로, 모든 영역은 직사각형 형태를 가지고 영역 내에 펜스가 없다.

출력

오직 하나의 줄에 아침까지 살아있는 양과 늑대의 수를 의미하는 두 정수를 출력한다.

예제 입력 1

6 6
...#..
.##v#.
#v.#.#
#.o#.#
.###.#
...###

예제 출력 1

0 2

예제 입력 2

8 8
.######.
#..o...#
#.####.#
#.#v.#.#
#.#.o#o#
#o.##..#
#.v..v.#
.######.

예제 출력 2

3 1

예제 입력 3

9 12
.###.#####..
#.oo#...#v#.
#..o#.#.#.#.
#..##o#...#.
#.#v#o###.#.
#..#v#....#.
#...v#v####.
.####.#vv.o#
.......####.

예제 출력 3

3 5
W3sicHJvYmxlbV9pZCI6IjMxODQi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