Tag Archives: dfs

PKU 1088 解题报告

滑雪

Time Limit: 1000MS Memory Limit: 65536K

Description

Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子

 1  2  3  4  5
 
16 17 18 19  6
 
15 24 25 20  7
 
14 23 22 21  8
 
13 12 11 10  9

一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。

Input

输入的第一行表示区域的行数R和列数C(1 <= R,C <= 100)。下面是R行,每行有C个整数,代表高度h,0<=h<=10000。

Output

输出最长区域的长度。

Sample Input

5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

Sample Output

25

Source

SHTSC 2002

太长时间没有写代码了,我已经离这个领域越来越远了.快毕业了,编程对于我的意义也不是很大了,我将来所从事的行业用到程序设计的机会不会很多.如慧慧所说,ACM,程序设计什么的对于我也只剩一点精神上的东西了.

......

Read more »

SGU 101 解题报告

http://acm.sgu.ru/problem.php?contest=0&problem=101

101. Domino

time limit per test: 0.50 sec.
memory limit per test: 4096 KB

Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The blocks usually are called bones, dominoes, or pieces and sometimes men,stones, or even cards.
The face of each piece is divided, by a line or ridge, into two squares, each of which is marked as would be a pair of dice...

The principle in nearly all modern dominoes games is to match one end of a piece to another that is identically or reciprocally numbered.

ENCYCLOPÆDIA BRITANNICA

多米诺 – 一种使用木头或其他材料制作的方块进行的游戏。方块的每个面上标记上确定的数字或点。方块常常被称做骨,骨牌或片,有时使用人,骨头或卡片进行.

每个骨牌的面使用一条线分成两部分,每个部分标记一个数字.

几乎所有现代骨牌游戏的原则是:骨牌数字相同的部分首位相接,最后连成串.

–––––– 《大英百科全书》

Given a set of domino pieces where each side is marked with two digits from 0 to 6. Your task is to arrange pieces in a line such way, that they touch through equal marked sides. It is possible to rotate pieces changing left and right side.

给定一系列两端标记为0~6数字的骨牌.你的任务是排列这些骨牌,使他们相接触的部分数字相同,你可以左右翻转骨牌.

Input

The first line of the input contains a single integer N (1 ≤ N ≤ 100) representing the total number of pieces in the domino set. The following N lines describe pieces. Each piece is represented on a separate line in a form of two digits from 0 to 6 separated by a space.

第一行输入一个整数 N (1 ≤ N ≤ 100) 代表骨牌的数量. 接下来 N 行代表 N 块骨牌. 每块骨牌使用两个0~6的使用空格隔开的数字表示.

Output

Write “No solution” if it is impossible to arrange them described way. If it is possible, write any of way. Pieces must be written in left-to-right order. Every of N lines must contains number of current domino piece and sign “+” or “-“ (first means that you not rotate that piece, and second if you rotate it).

如果无法将骨牌连成串,则输出"No solution". 否则输出任何一种符合条件的排列方案.输出是从左到右描述骨牌的排列.每行包含一个数字和一个符号,分别表示骨牌的编号和是否翻转骨牌,(+表示不翻转,-表示翻转)。

Read more »