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

34458번 - Connecting Territories 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB146541.667%

문제

Ava is playing a strategic game on a grid of tiles. Each tile has an associated cost. When the costs of the tiles are read from left to right, starting with the first row, a repeating pattern of the first $M$ positive integers in increasing order is revealed: 1,ドル 2, 3, \dots , M, 1, 2, 3, \dots , M, 1, 2, 3, \dots $. In this pattern, $M$ represents the maximum cost of a tile. In the grid of tiles shown, $M$ is equal to 5ドル$.

Ava needs to purchase one tile in each row in order to make a connecting path from the upper territory (above the first row of tiles) to the lower territory (below the last row of tiles). The first tile purchased must be in the first row. Each subsequently purchased tile must share either an edge or a corner with the tile purchased previously. In the grid of tiles shown, the cost of Ava’s connecting path is 9ドル$.

Given a grid of tiles, your job is to determine the minimum cost of a connecting path between the upper and lower territories.

입력

The first line of input contains a positive integer, $R$ where $R ≤ 20,円 000,ドル representing the number of rows in the grid. The second line contains a positive integer, $C$ where $C ≤ 20,円 000,ドル representing the number of columns in the grid. The third line contains a positive integer, $M$ where $M ≤ 100,円 000,ドル representing the maximum cost of a tile.

출력

Output the positive integer, $P,ドル which is the minimum cost of a connecting path between the upper and lower territories.

제한

예제 입력 1

3
5
7

예제 출력 1

6

The cost of each tile is shown. The sequence of tiles that Ava should purchase to minimize the cost of a connecting path is highlighted in green.

노트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2025 > CCC 2025 Junior Division 5번

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

출처

대학교 대회

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

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