AcWing 1761 阻挡广告牌 题解(春季每日一题)

看到这个数据就可以直接二维涂色哈哈哈
AcWing 1761 阻挡广告牌

#include<bits/stdc++.h>

using namespace std;

const int N = 5010;

int an[N][N];//记录面积 
int n;
int ans;
int maxx, maxy;

int main()
{
	for(int i = 0; i < 2; i ++ ){
		int x1, x2, y1, y2;
		cin>>x1>>y1>>x2>>y2;
		x1 += 1000;
		x2 += 1000;
		y1 += 1000;
		y2 += 1000;
		maxx = max(maxx, max(x1, x2));
		maxy = max(maxy, max(y1, y2));
		for(int j = x1; j < x2; j ++ ){
			for(int k = y1; k < y2; k ++ ){
				an[j][k] = 1;
			}
		}
	}
	
	int x3, x4, y3, y4;
	cin>>x3>>y3>>x4>>y4;
	x3 += 1000;
	x4 += 1000;
	y3 += 1000;
	y4 += 1000;
	maxx = max(maxx, max(x3, x4));
	maxy = max(maxy, max(y3, y4));		
	for(int j = x3; j < x4; j ++ ){
		for(int k = y3; k < y4; k ++ ){
			an[j][k] = 3;
		}
	}	
	
	for(int i = 0; i <= maxx; i ++ ){
		for(int j = 0; j <= maxy; j ++ ){
			if(an[i][j] == 1){
				ans ++ ;
			}
			//cout<<an[i][j]<<' ';
		}
		//cout<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值