[HNOI2005]汤姆的游戏
直接O(n ^ 2)暴力判断就行了。
对于圆,判断该点和圆心的距离是否小于半径。
然而为啥我这么写编译不过:
- scanf("%lf%lf%lf%lf", &a[++cnt1].xl, &a[cnt1].yl, &a[cnt1].xr, &a[cnt1].yr);
++cnt1必须拎出来写?!……
- #include<cstdio>
- #include<iostream>
- #include<algorithm>
- #include<cmath>
- #include<cstring>
- #include<cstdlib>
- #include<vector>
- #include<queue>
- #include<stack>
- #include<cctype>
- using namespace std;
- #define enter puts("")
- #define space putchar(' ')
- #define Mem(a) memset(a, 0, sizeof(a))
- typedef long long ll;
- typedef double db;
- const int INF = 0x3f3f3f3f;
- const db eps = 1e-;
- const int maxn = 3e5 + ;
- const int maxm = 5e4 + ;
- inline ll read()
- {
- ll ans = ;
- char ch = getchar(), last = ' ';
- while(!isdigit(ch)) last = ch, ch = getchar();
- while(isdigit(ch)) ans = (ans << ) + (ans << ) + ch - '', ch = getchar();
- if(last == '-') ans = -ans;
- return ans;
- }
- inline void write(ll x)
- {
- if(x < ) putchar('-'), x = -x;
- if(x >= ) write(x / );
- putchar(x % + '');
- }
- int n, m;
- struct Rec
- {
- db xl, yl, xr, yr;
- }a[maxn];
- struct Cir
- {
- db x, y, r;
- }b[maxn];
- int cnt1 = , cnt2 = ;
- int ans[maxm];
- void judge(const db& x, const db& y, const int& id)
- {
- for(int i = ; i <= cnt1; ++i)
- {
- if(a[i].yl <= a[i].yr)
- {
- if(a[i].xl < x && a[i].xr > x && a[i].yl < y && a[i].yr > y) ans[id]++;
- }
- else if(a[i].xl < x && a[i].xr > x && a[i].yr < y && a[i].yl > y) ans[id]++;
- }
- for(int i = ; i <= cnt2; ++i)
- if((x - b[i].x) * (x - b[i].x) + (y - b[i].y) * (y - b[i].y) < b[i].r * b[i].r) ans[id]++;
- }
- int main()
- {
- n = read(); m = read();
- for(int i = ; i <= n; ++i)
- {
- char c[]; scanf("%s", c);
- if(c[] == 'r')
- {
- cnt1++;
- scanf("%lf%lf%lf%lf", &a[cnt1].xl, &a[cnt1].yl, &a[cnt1].xr, &a[cnt1].yr);
- if(a[cnt1].xl > a[cnt1].xr) swap(a[cnt1].xl, a[cnt1].xr), swap(a[cnt1].yl, a[cnt1].yr);
- }
- else cnt2++, scanf("%lf%lf%lf", &b[cnt2].x, &b[cnt2].y, &b[cnt2].r);
- }
- for(int i = ; i <= m; ++i)
- {
- db x, y; scanf("%lf%lf", &x, &y);
- judge(x, y, i);
- }
- for(int i = ; i <= m; ++i) write(ans[i]), enter;
- return ;
- }
[HNOI2005]汤姆的游戏的更多相关文章
- BZOJ 1199: [HNOI2005]汤姆的游戏 计算几何暴力
1199: [HNOI2005]汤姆的游戏 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/p ...
- 洛谷 P2313 [HNOI2005]汤姆的游戏 题解
P2313 [HNOI2005]汤姆的游戏 题目描述 汤姆是个好动的孩子,今天他突然对圆规和直尺来了兴趣.于是他开始在一张很大很大的白纸上画很多很多的矩形和圆.画着画着,一不小心将他的爆米花弄撒了,于 ...
- 几何【P2313】 [HNOI2005]汤姆的游戏
顾z 你没有发现两个字里的blog都不一样嘛 qwq 题目描述--->p2313 [HNOI]汤姆的游戏 分析 说不上是分析. 数据范围给出来,这题明显暴力啊emmm. 个人认为的坑点. 这题不 ...
- 1199: [HNOI2005]汤姆的游戏 - BZOJ
Description 汤姆是个好动的孩子,今天他突然对圆规和直尺来了兴趣.于是他开始在一张很大很大的白纸上画很多很多的矩形和圆.画着画着,一不小心将他的爆米花弄撒了,于是白纸上就多了好多好多的爆米花 ...
- P2313 [HNOI2005]汤姆的游戏
题目描述 汤姆是个好动的孩子,今天他突然对圆规和直尺来了兴趣.于是他开始在一张很大很大的白纸上画很多很多的矩形和圆.画着画着,一不小心将他的爆米花弄撒了,于是白纸上就多了好多好多的爆米花.汤姆发现爆米 ...
- bzoj千题计划176:bzoj1199: [HNOI2005]汤姆的游戏
http://www.lydsy.com/JudgeOnline/problem.php?id=1199 求出圆x的范围 把要判断的点按x从小到大排序 枚举图形 二分出x满足这个图形的一段区间 枚举这 ...
- 汤姆大叔 javascript 系列 第20课 最后的5到javascript题目
博客链接:http://www.cnblogs.com/TomXu/archive/2012/02/10/2342098.html 原题: 大叔注:这些题目也是来自出这5个题目的人,当然如果你能答对4 ...
- 你必须知道ASP.NET知识------关于动态注册httpmodule(对不起汤姆大叔)
一.关于动态注册的问题 很多人看过汤姆大叔的MVC之前的那点事儿系列(6):动态注册HttpModule ,其实汤姆大叔没有发现httpmodule动态注册的根本机制在哪里. 亦即:怎么动态注册?为什 ...
- 我读汤姆大叔的深入理解js(二)
继续汤姆大叔的js之旅. 揭秘命名函数表达式 函数表达式和函数声明 汤姆大叔在博客中引用ECMA规范:函数声明必须带有标识符,函数表达式可以省略.对于我来说这些概念的东西真是不所适从.还是大叔的实例带 ...
随机推荐
- 针对Eclipse闪退的两种解决方案
闪退情况是:双击Eclipse登陆按钮,显示图标后,紧接着关闭: 1. 到eclipse文件夹中的eclipse.ini打开编辑在最后加入下面代码保存即可 -Dorg.eclipse.swt.brow ...
- Recommend ways to overwrite hashCode() in java
Perface In the former chapter, I talk about topics about hashCode, And I will continue to finish the ...
- bzoj1061 NOI2018 志愿者招募——solution
Description 申奥成功后,布布经过不懈努力,终于成为奥组委下属公司人力资源部门的主管.布布刚上任就遇到了一个难 题:为即将启动的奥运新项目招募一批短期志愿者.经过估算,这个项目需要N 天才能 ...
- 浏览器根对象navigator之客户端检测
Navigator的5个主要属性: appName:Web浏览器的名称 appVersion:浏览器的版本号和其他版本信息 userAgent:浏览器在它的USER-AGENT HTTP标题中发送的字 ...
- windows如何查看nvidia显卡(GPU)的利用率和温度
windows如何查看nvidia显卡(GPU)的利用率和温度 nvidia-smi 只要在文件夹C:\Program Files\NVIDIA Corporation\NVSMI里找到文件nvidi ...
- 使用Callable和Future接口创建线程
具体是创建Callable接口的实现类,并实现clall()方法.并使用FutureTask类来包装Callable实现类的对象,且以此FutureTask对象作为Thread对象的target来创建 ...
- clipChildren属性
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-5: ordin al not in range(128)——解决方案备注
在vim中使用ycm插件时,偶尔会出现: “UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-5: ord ...
- 【日常记录】【unity3d】 OnTriggerEnter 和 OnCollisionEnter (2D) 的区别
问题:两个物体A,B 两者都有碰撞体 collider(Box Collider,Sphere Collider,Capsule Collider等)当两物体相撞时,会进入 OnTriggerEnte ...
- Sql Server tempdb原理-启动过程解析实践
我们知道在SqlServer实例启动过程中数据库会进行还原(Redo,Undo)然后打开提供服务,但我们知道tempdb是不提供重做机制的(Redo)那tempdb是如何还原的呢?如果tempdb损坏 ...