【CS Round #43 B】Rectangle Partition
2024-10-01 20:41:23
【链接】https://csacademy.com/contest/round-43/task/rectangle-partition/
【题意】
水题
【题解】
横着过去,把相邻的边的宽记录下来.
竖着再扫描一遍,看看有没有出现和之前相同的宽度的.有的话,贡献的正方形个数++
【错的次数】
0
【反思】
在这了写反思
【代码】
#include<bits/stdc++.h> using namespace std; int h,w,n,m;
int x[100000+10],y[100000+10];
map<int,int>dic; int main()
{
cin>>h>>w>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>x[i];
}
for(int i=1;i<=m;i++)
{
cin>>y[i];
}
sort(x+1,x+1+n);
n++;
x[n]=h; sort(y+1,y+1+m);
m++;
y[m]=w; int pre=0;
for(int i=1;i<=n;i++)
{
int temp=x[i]-pre;
dic[temp]++;
pre=x[i];
}
pre=0;
long long ans=0;
for(int i=1;i<=m;i++)
{
int temp=y[i]-pre;
ans=ans+dic[temp];
pre=y[i];
}
cout<<ans<<endl;
return 0;
}
最新文章
- C#调用LUA函数
- ECharts学习(2)--饼状图之南丁格尔图
- 用JAVA写一个日历计划
- 操作集合的工具类:Collections
- linux命令细究
- Sky数[HDU2097]
- 杭电1002-A + B Problem II
- Alignment
- Map的遍历
- nutch http file 截断问题
- Linux Shell脚本编程--sed命令详解
- 传输层socket通讯之java实现
- 二分求最长上升子序列 二分LIS
- jquery touch 移动端上下滑动加载
- weblogic patch log显示
- golang 使用pprof进行性能调优
- DAY15、模块
- 基于ROS完成寻迹运动
- 华莱士的 第一个python程序之(用户登录)
- python 内建函数__new__的单例模式