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

Patkice2

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

의견: 0

설명

After Holywood got its hands on the fascinating story of the successful umbrella voyage
between two islands, Netflix executives decided to make a series adaptation of the
three ducks’ travels.
As you may remember from the first round of COCI \(20/21\), the ducks have a map of
ocean currents. The ducks travel together. The island where the ducks live is marked
by the letter ’o’. The ducks can start their voyage in any of the four directions. Ocean currents in these
seas move in one of the four directions, and are marked in the following way: we\(st-ea\)st ’>’, ea\(st-we\)st
’<’, nor\(th-so\)uth ’v’ and sou\(th-no\)rth ’^’. When the ducks are located on a cell with a current, they will
move one cell in the direction of the current.
Calm sea is marked by a dot ’.’. If the currents bring the ducks to a cell with calm sea, outside the
map, or back to the starting island, they will stop their voyage. The island that the ducks want to visit is
marked by ’x’.
In order to make the series more appealing, Netflix made a few changes to the story: the sea now may
contain wild vortexes (the ducks can get stuck in a cycle) and sea currents that carry the ducks outside
the map. ^{∗}
Therefore, the original map of currents has been changed. But under heavy deadline pressure, the director
has made some mistakes: the ducks cannot arrive from the initial to the target island via sea currents
anymore.
Netflix directors are very important persons, so they don’t really spend time contemplating plot holes.
Thus it is your task now to replace as few as possible characters on the map, so that the ducks can
go from the initial to the target island.
For story purposes, the cells with (’o’ and ’x’) cannot be modified. All other cells are either sea
currents or calm sea (characters ’<>v^.’). You can replace characters in those cells with characters from
the same set ’<>v^.’.

제약

Subtask 1 (30 points): \(3 \le r\), \(s \le 20\)

Subtask 2 (80 points): No additional constraints. If in all test cases in some subtaks the first line (minimum number of changes) is correct, but the map in some test case is not valid, you will get half of the points for that subtask.

입력 형식

The first line contains integers \(r\) and \(s\) (\(3 \le r\), \(s \le 2000\)), the number of rows and columns of the map.
Each of the following \(r\) lines contains \(s\) characters from the set ’o<>v^.x’, that represent the map of
ocean currents. There will always be exactly one character ’o’ and exactly one character ’x’ on the map,
and they will not be adjacent.

출력 형식

In the first line output \(k\), the minimum number of changes so that the ducks can go from the initial to the
target island.
In the each of the next \(r\) lines, output \(s\) characters, describing a map which differs from the input map in
exactly \(k\) cells, satisfying the requirements of the problem.
If there are multiple valid maps, output any of them.
^{∗}The ducks also form a heartbreaking love triangle, but that is not important right now.

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

1

30점

\(3 \le r\), \(s \le 20\)

2

80점

No additional constraints. If in all test cases in some subtaks the first line (minimum number of changes) is correct, but the map in some test case is not valid, you will get half of the points for that subtask.

예제 1
입력
3 3
>vo
vv>
x>>
출력
1
>vo
vv>
x<>
예제 2
입력
3 6
>>vv<<
^ovvx^
^<<>>^
출력
2
>>vv<<
^o>>x^
^<<>>^
예제 3
입력
4 4
x.v.
.>.<
>.<.
.^.o
출력
4
x<<.
.>^<
>.<^
.^.o
문제 정보

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

출처 COCI 2020/2021 Contest 4

평가 및 의견

Patkice2

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

Log in to rate problems.

개별 의견

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

풀이 제출

Patkice2

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