当前位置:网站首页>AcWing 1749. 阻挡广告牌 II(分类讨论+枚举)
AcWing 1749. 阻挡广告牌 II(分类讨论+枚举)
2022-04-21 10:38:00 【岁忧】
题目:1749. 阻挡广告牌 II


题解:最后没被遮盖住的部分,分别投影到x轴和y轴上的长度,相乘就是答案。等价于在没遮盖的部分找到x轴上的最大、小值。y轴也是如此。两者相乘即可。注意都被遮盖住的话,就找不到最大小值,所以就要记得和0比较
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<int ,int> PII;
const int N=1e5+10;
const int mod=100000007;
bool sta[2050][2050];
int main(){
int a[3][4];
int sum=0;
for(int i=0;i<2;i++){
cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
}
for(int k=0;k<2;k++){
for(int i=a[k][0]+1000;i<a[k][2]+1000;i++){
for(int j=a[k][1]+1000;j<a[k][3]+1000;j++){
if(k==0){
sta[i][j]=1;
}else{
sta[i][j]=0;
}
}
}
}
int b=2050,c=2050,d=0,e=0;//b、d记录x轴上最小、大值。c,e记录y轴上最小、大值
for(int i=a[0][0]+1000;i<a[0][2]+1000;i++){
for(int j=a[0][1]+1000;j<a[0][3]+1000;j++){
if(sta[i][j]){
b=min(b,i),d=max(d,i);
c=min(c,j),e=max(e,j);
}
}
}
cout<<max(0,d-b+1)*max(0,e-c+1);//注意都被遮盖住的情况
return 0;
}
版权声明
本文为[岁忧]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_46028214/article/details/124312558
边栏推荐
- torch.autograd.Function 自定义
- 本地IP地址使用域名访问
- 看完这篇 教你玩转渗透测试靶机vulnhub——DC9
- You don't know parseInt?
- L1-045 宇宙无敌大招呼 (5 分)
- Pytoch learning notes (2) examples of univariate linear regression and calculation diagram
- Zsh: segmentation fault solution
- bash shell中的退出状态码
- Pytoch learning notes (3) torch Autograd, logistic regression model, training
- Vulnhub PRIME: 1
猜你喜欢

Wonderful preview of the event 𞓜 Vitas + Long Zhi: building the "number one player" in the game industry digitally

2022信息与未来预备刷题3《New Online Judge 1059: 字符串排序》

Vulnhub PRIME: 1

zsh: segmentation fault 解决方法

Enter the welcome interface when idea and pycharm are started

“空气洗”再迎迭代,模仿者又有了新目标

本地IP地址使用域名访问

AOT和单文件发布对程序性能的影响

Moore thread cooperates with ampere computing

Summary of knapsack problem (0-1, complete, multiple knapsack problem)
随机推荐
Summary of knapsack problem (0-1, complete, multiple knapsack problem)
"Air washing" meets the iteration again, and the imitator has a new goal
Pytoch learning notes (2) examples of univariate linear regression and calculation diagram
设计一个高质量的 API 接口
Enter the welcome interface when idea and pycharm are started
SAP ABAP FOR ALL ENTRIES 的用法
Vulnhub PRIME: 1
Wonderful preview of the event 𞓜 Vitas + Long Zhi: building the "number one player" in the game industry digitally
2-3. Register selector
活动精彩预告 | 维塔士+龙智:数字化打造游戏行业「头号玩家」
Opencv -- template matching
Usage of SAP ABAP for all entries
ConvBERT: Improving BERT with Span-based Dynamic Convolution论文的阅读笔记
内存模型和名称空间知识点总结
塔米狗企业并购平台上,法律服务商名单目录!
背包问题小结(0-1,完全,多重背包问题)
C语言 字符串
A collection of econometric models and empirical Stata codes, with top publication examples
Tamigou enterprise M & a platform, list of legal service providers!
Android learning ① various reasons why Android cannot connect to MySQL database and Solutions