| 比赛 | 
    20120417 | 
    评测结果 | 
    AAATTTTWTW | 
    | 题目名称 | 
    矩阵 | 
    最终得分 | 
    30 | 
    | 用户昵称 | 
    Makazeu | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2012-04-17 11:32:05 | 
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <set>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define MAXN 1100
using namespace std;
int N,M,Map[MAXN][MAXN];
set<int> Set[MAXN][MAXN];
int main()
{
	freopen("matrixa.in","r",stdin);
	freopen("matrixa.out","w",stdout);
	while(scanf("%d %d",&M,&N)!=EOF) 
	{
		loop(i,1,M) loop(j,1,N)	scanf("%d",&Map[i][j]);
		loop(i,1,M) loop(j,1,N)	{set_union(Set[i][j-1].begin(), Set[i][j-1].end(),Set[i-1][j].begin(), Set[i-1][j].end(),inserter(Set[i][j], Set[i][j].begin()));Set[i][j].insert(Map[i][j]);}
		loop(i,1,M) {loop(j,1,N)	{printf("%d ",Set[i][j].size()); }printf("\n");}
	}
	return 0;
}