Aizu - 0531 Paint Color

白书例题,直接用书上的暴力压缩坐标是可以的,但是看了别人的博客的写法,大概是理解了思想但是看不懂为什么那么压缩,先放这,等明白了补上

#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>PLL;
typedef pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const double eps=1e-8;
const ll maxn =1e3+200;
const int N = 1e4+10;
const ll mod=1000007;
//
int dx[]= {0,1,-1,0};
int dy[]= {1,0,0,-1};
int fld[2*maxn][2*maxn];
int X1[maxn],X2[maxn],Y1[maxn],Y2[maxn];
int W,H,n;
//
int compress(int *x1,int *x2,int w) {
	vector<int>xs;
	//
	for(int i=0; i<n; i++) {
		int tx1=x1[i],tx2=x2[i];
		if(1<=tx1&&tx1<w)
			xs.push_back(tx1);
		if(1<=tx2&&tx2<w)
			xs.push_back(tx2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(int i=0; i<n; i++) {
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
		cout<<x1[i]<<" "<<x2[i]<<endl;
	}
	return xs.size()-1;
}
//
int bfs() {
	int ans=0;
	//
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(fld[i][j])
			continue;
			ans++;
			queue<pair<int,int> >q;
			q.push(make_pair(j,i));
			while(!q.empty()){
				int sx=q.front().first,sy=q.front().second;
				q.pop();
				//
				for(int k=0;k<4;k++){
					int tx=sx+dx[k],ty=sy+dy[k];
					if(tx<0||W<tx||ty<0||H<ty||fld[ty][tx]>0)
					continue;
					q.push(make_pair(tx,ty));
					fld[ty][tx]=1;
				}
			}
		}
	}
	return ans;
}
//
void solve() {
	int i,j,tt=1;
	while(cin>>W>>H) {
		cin>>n;
		for(i=0; i<n; i++) {
			cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
		}
		memset(fld,0,sizeof(fld));
		//
		W=compress(X1,X2,W);
		H=compress(Y1,Y2,H);
		cout<<endl;
		for(i=0; i<n; i++) {
			cout<<X1[i]<<" "<<Y1[i]<<" "<<X2[i]<<" "<<Y1[i]<<endl;
		}
		//
		for(i=0; i<n; i++) {
			fld[Y1[i]][X1[i]]++;
			fld[Y2[i]][X2[i]]++;
			fld[Y1[i]][X2[i]]--;
			fld[Y2[i]][X1[i]]--;
		}
		//
		for(i=0; i<H; i++) {
			for(j=1; j<W; j++) {
				fld[i][j]+=fld[i][j-1];
			}
		}
		for(i=1; i<H; i++) {
			for(j=0; j<W; j++) {
				fld[i][j]+=fld[i-1][j];
			}
		}
		for(i=0; i<H; i++) {
			for(j=0; j<W; j++) {
				cout<<fld[i][j]<<" ";
			}
			cout<<endl;
		}
		//
		//		cout<<bfs()<<endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
#ifdef debug
	freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
	cin.tie(0);
	cout.tie(0);
	solve();
	/*
		#ifdef debug
			fclose(stdin);
			fclose(stdout);
			system("out.txt");
		#endif
	*/
	return 0;
}

  

转载于:https://www.cnblogs.com/visualVK/p/8483643.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的纺织品企业财务管理系统,源码+数据库+毕业论文+视频演示 在如今社会上,关于信息上面的处理,没有任何一个企业或者个人会忽视,如何让信息急速传递,并且归档储存查询,采用之前的纸张记录模式已经不符合当前使用要求了。所以,对纺织品企业财务信息管理的提升,也为了对纺织品企业财务信息进行更好的维护,纺织品企业财务管理系统的出现就变得水到渠成不可缺少。通过对纺织品企业财务管理系统的开发,不仅仅可以学以致用,让学到的知识变成成果出现,也强化了知识记忆,扩大了知识储备,是提升自我的一种很好的方法。通过具体的开发,对整个软件开发的过程熟练掌握,不论是前期的设计,还是后续的编码测试,都有了很深刻的认知。 纺织品企业财务管理系统通过MySQL数据库与Spring Boot框架进行开发,纺织品企业财务管理系统能够实现对财务人员,员工,收费信息,支出信息,薪资信息,留言信息,报销信息等信息的管理。 通过纺织品企业财务管理系统对相关信息的处理,让信息处理变的更加的系统,更加的规范,这是一个必然的结果。已经处理好的信息,不管是用来查找,还是分析,在效率上都会成倍的提高,让计算机变得更加符合生产需要,变成人们不可缺少的一种信息处理工具,实现了绿色办公,节省社会资源,为环境保护也做了力所能及的贡献。 关键字:纺织品企业财务管理系统,薪资信息,报销信息;SpringBoot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值