多萝西的奇遇 (seek.*)
【题目描述】
She was awakened by a shock, so sudden and severe that if Dorothy had not been lying on the soft bed she might have been hurt.
As it was, the jar made her catch her breath and wonder what had happened; and Toto put his cold little nose into her face and whined dismally.
Dorothy sat up and noticed that the house was not moving; nor was it dark, for the bright sunshine came in at the window, flooding the little room.
She sprang from her bed and with Toto at her heels ran and opened the door.
The little girl gave a cry of amazement and looked about her, her eyes growing bigger and bigger at the wonderful sights she saw.
The cyclone had set the house down very gently—for a cyclone—in the midst of a country of marvelous beauty. There were lovely patches of greensward all about, with stately trees bearing rich and luscious fruits. Banks of gorgeous flowers were on every hand, and birds with rare and brilliant plumage sang and fluttered in the trees and bushes. A little way off was a small brook, rushing and sparkling along between green banks, and murmuring in a voice very grateful to a little girl who had lived so long on the dry, gray prairies.
如上文,多萝西降落在了一个不可思议的平原上。而好奇的小H这时却发出了一个不和时宜地发言:我想知道这个平原上有多少个高峰和低谷。
为了满足小H的好奇心,并且把她赶到一遍凉快去,我们决定请你来回答这个问题。
你可以选择输出:
“You silly bitch.Why are you so □□ing stupid?”然后爆零,你也可以选择为她解决这个问题。
已知小H有一个将复杂问题简单化的习惯,于是她将平原简化成了一个N*M的矩阵,矩阵中每一块地的高度都可以简化为一个int型的整数。在小H的意识中,
高峰指:一块连通的区域,其中的数值都相同,并且该数值比周围的其它部分的数值大。
低谷指:一块连通的区域,其中的数值都相同,并且该数值比周围的其它部分的数值小。
注意,以上连通,相邻均是指4连通,即:上下左右连通。
【输入】
第一行两个整数N,M。
接着N行,每行有M个数字,表示高度信息,之间用一个空格隔开。
【输出】
输出一行两个整数,分别表示湖泊个数和山峰个数,之间用一个空格隔开。
【样例输入1】
2 2
1 2
1 1
【样例输出1】
1 1
【样例输入2】
3 4
1 3 2 6
1 2 2 7
3 2 2 5
【样例输出2】
1 3
【数据规模】
对于20%的数据: N,M ≤ 10。
对于60%的数据: N,M ≤ 100。
对于100%的数据: N,M ≤ 1000;高度 ≤ 1000000000。
信息
- 难度
- 9
- 分类
- (无)
- 标签
- 递交数
- 3
- 已通过
- 2
- 通过率
- 67%
- 上传者