返回顶部

阻塞的广告牌

这道题纯模拟,开个数组照题目写。

#include <bits/stdc++.h>
using namespace std;
int m[2200][2200],ans=0;
int main() {
	int a,d,s,f;
	for (int x=1; x<4; x++) {
		cin >> a >> s >> d >> f;
		for (int y = a + 1000; y < d + 1000; y++) {
			for (int z = s + 1000; z < f + 1000; z++) {
				if (x < 3) { // 如果是前两个
					m[y][z]++,ans++; // ans 此时为总面积
				}
				if (m[y][z] && x == 3) { // 如果是第三个且重叠
					ans--;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

代码简单,不多说。

posted @ 2022-01-23 11:08  zrc4889  阅读(28)  评论(0编辑  收藏  举报