当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1764:Dice Contest

题目描述
Everyone loves gambling in the Dicent City. Every Saturday the whole community meets to attend a dice contest. They started a few years ago with a classic six-sided die with 1 to 6 dots displayed on the sides and had a lot of fun.

However they soon got bored and that's why more sophisticated dice are in use nowadays. They put a sticker on each side and write a positive integer on each sticker.

The contest is run on a strip divided into squares in a chessboard-like manner. The strip is 4 squares wide and infinite to the left and to the right (is anyone going to say it can't exist in the real world, huh?). The rows of the strip are numbered from 1 to 4 from the bottom to the top and the columns are numbered by consecutive integers from the left to the right. Each square is identified by a pair (x,y) where x is a column number and y is a row number.

The game begins with a die placed on a square chosen be a contest committee with one-dot side on the top and two-dots side facing the player. To move the die the player must roll the die over an edge to an adjacent (either horizontally or vertically) square. The number displayed on the top of the die after a roll is the cost of the move. The goal of the game is to roll the die from the starting square to the selected target square so that the sum of costs of all moves is minimal.

Task
Write a program that:

reads the description of a die, a starting square and a target square,
computes the minimal cost of rolling the die from the starting square to the target square,
writes the result.
Note: all teams participating in the contest received dice from the organisers.
输入解释
The first line of the input contains six integers l1, l2, l3, l4, l5, l6 (1 < = li < = 50) separated by single spaces. Integer li is the number written on a side having originally i dots. The second line of the input contains four integers x1, y1, x2, y2 ( -109 < = x1, x2 < = 109, 1 <= y1, y2 < = 4) separated by single spaces. Integers x1, y1 are the column and the row number of the starting square respectively. Integers x2, y2 are the column and the row number of the target square respectively.
输出解释
The first and the only line of the output should contain the minimal cost of rolling the die from the starting square to the target square.
输入样例
1 2 8 3 1 4
-1 1 0 2
输出样例
7
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 2000MS

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Central Europe 2003

源链接: POJ-1764

最后修改于 2020-10-29T06:13:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000 10000