题意:给定平面上的N个点,属性分别标记为0和1,然后找一条直线,直线上的点全部溶解,一侧的1溶解,另一侧的0溶解。求出最多能溶解的点的个数。

思路:暴力枚举每个点,扫描线旋转。先做优化,如果一侧溶解0,则把属性为1的做关于当前枚举直线对称的点,这样统计一侧的点加上线上的点就是答案。O(n2).

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define clc(a,b) memset(a,b,sizeof(a))
#define eps 1e-8
typedef long long LL;
const int mod=;
const int inf=0x3f3f3f3f;
using namespace std;
#define N 100010 struct node
{
int x,y,r;
double ang;
}v[],rem[]; int cmp(const struct node a,const struct node b)
{
if(a.ang<b.ang)
return ;
else
return ;
} int sig (double a)
{
if(fabs(a)<eps)
return ;
else if(a>)
return ;
else
return -;
} int cross(struct node a,struct node b,struct node c)
{
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
} int main()
{
int n;
while(~scanf("%d",&n)&&n)
{
int ans=;
for(int i=;i<n;i++)
{
scanf("%d%d%d",&v[i].x,&v[i].y,&v[i].r);
rem[i]=v[i];
}
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
v[j]=rem[j];
if(v[j].r==)
{
v[j].x=rem[i].x*-v[j].x;
v[j].y=rem[i].y*-v[j].y;
}
v[j].ang=atan2(v[j].y-rem[i].y,v[j].x-rem[i].x);
}
swap(v[i],v[]);
sort(v+,v+n,cmp);
for(int j=,t=;j<n&&sig(v[j].ang)<=;j++)
{
int on=;
for( ;t<n&&cross(v[],v[j],v[t])>=;t++)
{
if(cross(v[],v[j],v[t])==)
on++;
}
ans=max(ans,max(t-j+,n-(t-j+)+on));
}
}
cout<<ans<<endl;
}
return ;
}

POJ 2280&&hdu 1661的更多相关文章

  1. POJ 2104&HDU 2665 Kth number(主席树入门+离散化)

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 50247   Accepted: 17101 Ca ...

  2. poj 1251 poj 1258 hdu 1863 poj 1287 poj 2421 hdu 1233 最小生成树模板题

    poj 1251  && hdu 1301 Sample Input 9 //n 结点数A 2 B 12 I 25B 3 C 10 H 40 I 8C 2 D 18 G 55D 1 E ...

  3. Eight POJ - 1077 HDU - 1043 八数码

    Eight POJ - 1077 HDU - 1043 八数码问题.用hash(康托展开)判重 bfs(TLE) #include<cstdio> #include<iostream ...

  4. POJ 1177/HDU 1828 picture 线段树+离散化+扫描线 轮廓周长计算

    求n个图矩形放下来,有的重合有些重合一部分有些没重合,求最后总的不规则图型的轮廓长度. 我的做法是对x进行一遍扫描线,再对y做一遍同样的扫描线,相加即可.因为最后的轮廓必定是由不重合的线段长度组成的, ...

  5. POJ 1308&&HDU 1272 并查集判断图

      HDU 1272 I - 小希的迷宫 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  6. POJ 1077 && HDU 1043 Eight A*算法,bfs,康托展开,hash 难度:3

    http://poj.org/problem?id=1077 http://acm.hdu.edu.cn/showproblem.php?pid=1043 X=a[n]*(n-1)!+a[n-1]*( ...

  7. POJ 2342 &&HDU 1520 Anniversary party 树形DP 水题

    一个公司的职员是分级制度的,所有员工刚好是一个树形结构,现在公司要举办一个聚会,邀请部分职员来参加. 要求: 1.为了聚会有趣,若邀请了一个职员,则该职员的直接上级(即父节点)和直接下级(即儿子节点) ...

  8. POJ 1904 HDU 4685

    这两道题差不多,POJ这道我很久以前就做过,但是比赛的时候居然没想起来.. POJ 这道题的题意是,N个王子每个人都有喜欢的公主,当他们选定一个公主结婚时,必须是的剩下的人也能找到他喜欢的公主结婚. ...

  9. 【中国剩余定理】POJ 1006 & HDU 1370 Biorhythms

    题目链接: http://poj.org/problem?id=1006 http://acm.hdu.edu.cn/showproblem.php?pid=1370 题目大意: (X+d)%23=a ...

随机推荐

  1. The Introduction of Java Memory Leaks

    One of the most significant advantages of Java is its memory management. You simply create objects a ...

  2. Hibernate学习笔记(1)

    1 使用Hibernate (1)创建User Library,命名为HIBERNATE3,加入需要的jar (2)创建hibernate配置文件hibernate.cfg.xml, 为了便于调试最好 ...

  3. VCC_VID_VTT等的含义

    VCC--为直流电压.在主板上为主供电电压或一般供电电压.例如 一般电路VCC3--+3V供电.主板上VCC3: 3.3V VCC25: 2.5V VCC333: 3.3V VCC5: 5V VCC1 ...

  4. Support Library官方教程(1)概述

    Support Library The Android Support Library package is a set of code libraries that provide backward ...

  5. tc 2014 college tour 250 500

    题意: You are given a long long n. Return the largest divisor of n that is a perfect square. That is, ...

  6. bzoj1567: [JSOI2008]Blue Mary的战役地图

    将矩阵hash.s[0]忘了弄成0,输出中间过程发现了. hash.sort.判重.大概这样子的步骤吧. #include<cstdio> #include<cstring> ...

  7. ElasticSearch Remote Code Execution (CVE-2014-3120)

    Elasticsearch is a powerful open source search and analytics engine. The vulnerability allows attack ...

  8. BZOJ1049: [HAOI2006]数字序列

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1049 题解: ydc的题解:http://pan.baidu.com/share/link?u ...

  9. RecyclerView 结合 CardView 使用(二)

    上一篇的基础上,修改了,CardView的布局和点击效果 总结: CardView的奇葩属性 :app:cardPreventCornerOverlap="false" 和园角边框 ...

  10. BZOJ 3573 米特运输

    语文题... 原来除了hash还可以取对数啊orz #include<iostream> #include<cstdio> #include<cstring> #i ...