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

34440번 - Tree Skiing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
11 초 2048 MB29272095.238%

문제

After a long drive, you and your friend have arrived at the ski slope. There is a ton of new snow, the sun is shining, and you are both feeling adventurous! When you get off the lift, you see that a new run has been opened through the trees. Strangely, the trees in this forest have grown in a perfectly compass-aligned grid.

Your friend heads off down the slope weaving her way around the trees. Eventually, she stops in a clearing to make a snow angel. You want to join her to make a snow angel as well, but you do not want to waste the opportunity to ski on the fresh powder. You go looking for a new path through the forest.

You can't ski straight down the mountain to your friend because there are trees in the way. At each clearing you have an option to head directly north or directly west out of the clearing. You don't want to climb back uphill to the south or east. Once you pass the clearing and enter the next, you have to make the same decision again and again. How many different ways can you ski through the trees until you reach the clearing where your friend is playing in the snow, without skiing on exactly the same path as she skied and without hitting a tree on your way down?

Figure 1: Representation of Sample Input 1. In pink, your friend's path down the mountain. In blue, your two possible paths.

입력

The first line of input contains an integer 1ドル \leq n \leq 20$. The second line of input contains $n$ characters separated by spaces which specify, in order, the directions your friend went at each clearing. The characters are limited to N for north and W for west.

출력

The output should contain a single integer: the number of other possible paths you could take to meet up with your friend. For example, in Sample Input 1ドル$ there are 3ドル$ paths total to the clearing where your friend is making snow angels. Your friend went north, north again, then west. You can go either north, west, then north or west, north, then north. So there are 2ドル$ new ways for you to get to the clearing. Note that the output could be 0ドル$ if, for example, your friend took the only path to the clearing.

제한

예제 입력 1

3
N N W

예제 출력 1

2

예제 입력 2

4
N W N W

예제 출력 2

5

노트

출처

School > CS@Mines > CS@Mines HSPC 2019 E번

  • 문제를 만든 사람: Sam Sartor
(追記) (追記ここまで)

출처

대학교 대회

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

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