题目链接:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118 题意:给定一个矩阵,同类字符相连的为一个块,问总共有几个块. 输入:h,w(行和列)0 <= h <= 100,0 <= w <= 100 矩阵 输入包含多组用例,以0,0结束. 输出:块数. 代码: #include <iostream> using namespace std; typedef long long ll; #defin…
Red and Black Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12519 Accepted Submission(s): 7753 Problem Description There is a rectangular room, covered with square tiles. Each tile is color…
POJ1979 Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18201 Accepted: 9192 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6795 Accepted: 3622 Description Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the information that his cows are deathly afraid of wate…
Zhuge Liang's Mines Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 236 Accepted Submission(s): 107 Problem Description In the ancient three kingdom period, Zhuge Liang was the most famous a…
题意:没有儿子的节点所结苹果数是节点的编号,有儿子的所结苹果是儿子数量(k+1)/2个,求跟节点的苹果数 直接递归一下,先求出所有儿子的苹果树,在排序,,刚开始以为1就是根节点,根节点不确定,, #include<stdio.h> #include<string.h> #include<stdlib.h> const int N=20010; int w[N],vis[N],head[N],num,p[N]; struct edge { int st,ed,next;…