[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规范:函数声明必须带有标识符,函数表达式可以省略.对于我来说这些概念的东西真是不所适从.还是大叔的实例带 ...
随机推荐
- 宜立方商城中,mvn报错'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework:spring-webmvc:jar报错
'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.springframework:s ...
- K:跳表
跳表(SkipList)是一种随机化的数据结构,目前在redis和leveldb中都有用到它,它的效率和红黑树以及 AVL 树不相上下,但跳表的原理相当简单,只要你能熟练操作链表, 就能轻松实现一 ...
- 各种IDE的使用
sharpdevelop http://blog.sina.com.cn/s/blog_d1001bff0101di7p.html
- python之协程gevent模块
Gevent官网文档地址:http://www.gevent.org/contents.html 进程.线程.协程区分 我们通常所说的协程Coroutine其实是corporate routine的缩 ...
- 移动端Web Meta标签
原文 http://blog.segmentfault.com/jianjian_532633/1190000000654839 添加到推刊 在介绍移动端特有 meta 标签之前,先简单说一下 ...
- ORACLE 导出表结构及备注
https://blog.csdn.net/u013303551/article/details/52354230 SELECT t.table_name, t.colUMN_NAME, ...
- Weblogic集群配置__部署润乾应用
◆环境: Windows xp Weblogic:wls1031_ccjk_win32.rar(内部下载:\\192.168.0.38\SystemInstaller\4WebServer\we ...
- Android控件显示和隐藏
Android控件都有visibility属性,该属性有三个可能值:visible.invisible.gone.可以通过预设或是Java程序控制这些控件的显示或隐藏. 一.在XML配置文件设置 可见 ...
- 带你从零学ReactNative开发跨平台App开发(五)
ReactNative跨平台开发系列教程: 带你从零学ReactNative开发跨平台App开发(一) 带你从零学ReactNative开发跨平台App开发(二) 带你从零学ReactNative开发 ...
- 转:MVC框架
MVC框架是什么 MVC (Modal View Controler)本来是存在于Desktop程序中的,M是指数据模型,V是指用户界面,C则是控制器.使用MVC的目的是将M和V的实现代码分离,从而使 ...