UVa 10703 - Free spots
来源:互联网 发布:网站源码获取 编辑:程序博客网 时间:2024/06/05 23:52
题目:给定一个矩形点集,从里面扣掉一些小矩形点集,问最后还有多少个点。
分析:简单题。由于数据较小,暴力就可以了,数据大时,可使用线段树。
说明:
#include <algorithm> #include <iostream> #include <cstring>#include <cstdio> using namespace std; bool maps[505][505]; int main() { int w, h, n, x1, y1, x2, y2; while (~scanf("%d%d%d",&w,&h,&n) && w) { memset(maps, true, sizeof(maps)); for (int i = 0; i < n ; ++ i) {scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if (x1 > x2) swap(x1, x2); if (y1 > y2) swap(y1, y2); for (int j = x1; j <= x2 ; ++ j) for (int k = y1; k <= y2 ; ++ k) maps[j][k] = 0; } int ans = 0; for (int i = 1; i <= w ; ++ i) for (int j = 1; j <= h ; ++ j) if(maps[i][j])ans ++; if (ans == 0) printf("There is no empty spots.\n"); else if (ans == 1) printf("There is one empty spot.\n"); else printf("There are %d empty spots.\n",ans); } return 0; }
0 0
- UVa 10703 - Free spots
- uva 10118 Free Candies
- uva 10118 - Free Candies
- UVA - 10118 Free Candies
- UVA - 12260 Free Goodies
- uva 10118 - Free Candies
- UVA 10118 - Free Candies
- UVA - 10118 Free Candies
- UVA - 10118 Free Candies
- UVa 10118 Free Candies
- uva 10118 free candies
- UVA 10118 Free Candies
- UVA 10118 Free Candies
- uva 10118 Free Candies
- UVA 10118 Free Candies
- uva 10118Free Candies
- uva 10118 Free Candies
- Free Candies UVA
- nyoj-484-The Famous Clock
- java xml Serialize DeSerialize
- 2014/12/13 18:02
- 吐槽一下Levono B4400 win8转win7
- 如何加快Android应用启动速度
- UVa 10703 - Free spots
- HBase ORM SimpleHBase设计
- 蓝牙一主三从, 基于cc2540 cc2541 AMOMCU 蓝牙4.0开发板
- 互联网思维 | 七大主流趋势主导未来3年电商
- 插入排序算法
- 设计模式基础---UML关系的代码实现
- Jquery this的用法
- 随便记录
- 【BZOJ 1901】 Zju2112 Dynamic Rankings