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

I. Burglary

설명

The giant Candy-Bar Wall in the Royal Kitchen is used to store... well, candy bars. These are placed in jars on \(N\) equal-length shelves. The shelves are positioned in a vertical progression from the ground up, and perfectly aligned horizontally on their rightmost and leftmost edges. Each shelf is partitioned into \(M\) equal-sized slots, which can either be empty or occupied by a jar. A jar contains between 1 and 9 candy bars.

Every shelf is connected to the one directly below (or to the floor, for the bottommost shelf) by one or more vertical ladders. A ladder connects a slot to the corresponding slot on the shelf below, or to the floor. There is at most one ladder directly under any given slot.

The topmost shelf does not contain any jars, but just above it there is a huge open window leading to the Royal Kitchen rooftop. Mini-Fierce-And-Hungry Bandit has surprisingly managed to get into the Royal Kitchen via this top window and now plans a massive candy-bar burglary. More precisely, he intends to do a fun-and-profit "round trip" across the wall, that is:
- start from the topmost shelf;
- move down 0 or more shelves, possibly until reaching the floor;
- and then move up again, to the top window through which he will gracefully exit;

while of course grabbing as many candy bars as possible during this trip.

The major issue the bandit faces however is that he cannot enter a slot containing a candy jar more than once, since this would trigger a dreadful Candy Alarm.

Your mission: help the bandit carefully plan his round trip across the Candy-Bar Wall so as to maximize the number of candy bars he grabs, without triggering any alarm.

제약
입력 형식

The first line consists of two integers: \(N\) (number of shelves) and \(M\) (number of slots on a shelf), separated by a space. The following \(2N\) lines each consist of strings of length \(M\) depicting, in an ASCII art manner, the shelf and ladder configuration:
- Line \(2k\), for \(1\leq k\leq N\), comprises the characters '-', '1', ..., '9', where a digit \(x\) represents a jar containing \(x\) candy bars, and '-' denotes an empty slot.
- Line \(2k+1\), for \(1\leq k\leq N\), comprises the characters '.' and '|', where '|' represents a ladder, and '.' means empty wall space.

Limits
- \(1\leq N\leq 1\,000\);
- \(1\leq M\leq 5\,000\);
- there are between \(1\) and \(10\) ladders directly under any shelf.

출력 형식

The output consists of an integer on a single line, representing the maximum number of candy bars the bandit can collect without triggering any alarm.

예제 1
입력
5 20
--------------------
.|.....|...|......|.
1-1--1115-3-1-1--1-1
....|.........|.....
---1-11-1-11---1--3-
.......|.........|..
-7----9-4-----------
..|.................
--------9-----------
.|.................|
출력
38
문제 정보

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

출처 ICPC SWERC 2017

평가 및 의견

I. Burglary

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

Log in to rate problems.

개별 의견

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

풀이 제출

I. Burglary

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