【链接】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;
}

最新文章

  1. C#调用LUA函数
  2. ECharts学习(2)--饼状图之南丁格尔图
  3. 用JAVA写一个日历计划
  4. 操作集合的工具类:Collections
  5. linux命令细究
  6. Sky数[HDU2097]
  7. 杭电1002-A + B Problem II
  8. Alignment
  9. Map的遍历
  10. nutch http file 截断问题
  11. Linux Shell脚本编程--sed命令详解
  12. 传输层socket通讯之java实现
  13. 二分求最长上升子序列 二分LIS
  14. jquery touch 移动端上下滑动加载
  15. weblogic patch log显示
  16. golang 使用pprof进行性能调优
  17. DAY15、模块
  18. 基于ROS完成寻迹运动
  19. 华莱士的 第一个python程序之(用户登录)
  20. python 内建函数__new__的单例模式

热门文章

  1. Ubuntu16.04+Gnome3 锁定屏幕快捷键无效解决办法
  2. 【Redis发布订阅】
  3. gvim window7 下提示乱码
  4. 44.Node.js Express 框架--web框架
  5. 转 EL表达式
  6. Kali linux查看局域网内其他用户的输入信息
  7. col---过滤控制字符
  8. mkfs---创建Linux文件系统
  9. centos6.5下 python3.6安装、python3.6虚拟环境
  10. PythonOOP面向对象编程1