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

J4. Snail Path

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

A snail is crawling across an infinite grid of equally sized squares.
It can crawl horizontally (east and west) or vertically (north and
south), but it cannot crawl diagonally.

As the snail crawls, it leaves a trail of slime which makes the
squares of the grid it touches slimy.

For example, after the snail below crawls east \(3\) squares, there will be \(4\) slimy squares as shown.

Given the movements taken by the snail, your job is to determine how
many times the snail enters a slimy square.

Technical Notes

You might receive an unpredictable error message if your program uses
too much memory.

Python 3 submissions for this problem will be evaluated using the
standard interpreter python3 (Version 3.10.12) instead of
pypy3 7.3.9 (Version 3.8.13).

제약
입력 형식

The first line of input contains a positive integer, \(M\), representing the number of movements
taken by the snail.

The next \(M\) lines will specify
the snail's movements, in order. Each movement will contain an uppercase
directional letter (N, E, S, or
W), followed by a positive integer less than or equal to 20
representing the number of squares the snail crawls in that
direction.

출력 형식

Output the non-negative integer, \(T\), which is the number of times the snail
enters a slimy square.

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

1

26점

The snail will never crawl north or west of its initial position and will stay close to its initial position. — \(M \leq 20\)

2

20점

The snail will stay close to its initial position. — \(M \leq 20\)

3

41점

The snail may crawl quite far from its initial position. — \(M \leq 1200\)

4

13점

The snail may crawl extremely far from its initial position. — \(M \leq 200\,000\)

예제 1
입력
3
S2
N2
S3
출력
4
설명

The diagram shows the snail's path. Whenever the snail enters a
slimy square, a numbered circle is placed along the path.

Notice that a single slimy square can be entered multiple
times.

예제 2
입력
3
S2
W15
N20
출력
0
설명

The snail's path will consist of (38) slimy squares. However, the
snail never returns to a square after leaving it, so the snail never
enters a slimy square.

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2026 Junior

평가 및 의견

J4. Snail Path

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

J4. Snail Path

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