【CS Round #43 B】Rectangle Partition
round partition cs 43 rectangle
2023-09-14 09:03:49 时间
【链接】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; }
相关文章
- 前端测试题:(解析)Math.round(-11.5)和Math.ceil(-12.5)的输出结果是
- Codeforces Round #806 (Div. 4)(A~F)
- SnackDown 2017 Online Elimination Round Prefix XOR
- 「LibreOJ β Round #7」匹配字符串
- Codeforces Round #784 (Div. 4)(A~F)
- Public NOIP Round
- MySQL Error number: MY-011247; Symbol: ER_SHA_PWD_FAILED_TO_GENERATE_MULTI_ROUND_HASH; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-14252: invalid ALTER TABLE MODIFY PARTITION option for a Hash partition ORACLE 报错 故障修复 远程处理
- 数学对象Math ceil()、floor()、round()方法详解编程语言
- partition by深入理解 Oracle over Partition By(oracle的over)
- 圆满结束:MySQL 的实施与运行(round mysql)
- C#Math.Round()函数问题