Logo
(追記) (追記ここまで)

19191번 - Grid 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB832100.000%

문제

There is a city square in one country which looks exactly like a rectangular $N \times M$ grid. The government decided to hold a meeting of its supporters, so right now, the city square is full of people. More precisely, there is exactly one person in each cell of the grid.

Each person looks in one of the four cardinal directions: notrh, east, south, or west. But when two neighboring people look directly at each other, they get embarrassed because they know that they came to the meeting only to get paid.

The government is well aware of the situation, and so it doesn't want any pair of people to get embarrassed, because if there are enough people who understand that they came for a wrong reason, they can start a riot. Still, the meeting participants are greedy, so they will gladly turn 90ドル$ degrees in any desired direction any time they get paid 1ドル$ turning coin. Each person can be paid and turned several times.

The government wants to turn people in such way that in the resulting position, no two persons get embarrassed by looking directly at each other. Your task is to achieve that with the minimum amount of money spent.

입력

The first line of input contains two integers $N$ and $M,ドル the dimensions of the grid (1ドル \le N, M \le 50$). Each of the next $N$ lines describes one row of the grid. Each of these lines contains $M$ characters denoting the direction in which the persons are looking. Each of the characters is one of "^" (for notrh), ">" (for east), "v" (for south), or "<" (for west).

출력

Print the minimum amount of turning coins the government has to spend to avoid people getting embarrassed.

제한

예제 입력 1

3 3
>v<
>^<
^^^

예제 출력 1

2

예제 입력 2

1 10
>>><<<>><<

예제 출력 2

2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2015 > Day 7: Karelia Cup Day 1, Grand Prix of Karelia B번

Contest > Open Cup > 2014/2015 Season > Stage 8: Grand Prix of Karelia B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /