zoukankan      html  css  js  c++  java
  • 【CS Round #43 B】Rectangle Partition

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


  • 相关阅读:
    【ZJOI2017】树状数组
    【ZJOI2014】力
    【WC2017】挑战
    kube event 事件监控
    k8s nginx-ingress 504 timeout
    k8s 工具集
    jvm 性能调优工具之 jmap
    Elasticsearch unassigned 故障排查
    harbor API 与tag 清理
    前后端分离文档
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626078.html
Copyright © 2011-2022 走看看