题意:给定平面上的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. 安卓开发44:解决 INSTALL_FAILED_UID_CHANGED 等问题

    apk无法卸载,一般可以下面的方法试一下: 1. 删除/data/app/(filename) 文件夹下的apk包 2. 删除/system/app/(filename) 文件夹下的apk包 3. 将 ...

  2. 设计模式之Inheritance versus Parameterized Types 继承和参数化类型

    Another (not strictly object-oriented)technique for reusing functionality is through parameterized t ...

  3. testNG小试牛刀

    testNG是一个测试框架,其灵感来自JUnit和NUnit的,但引入了一些新的功能,使其功能更强大,使用更方便. testNG是一个开源自动化测试框架:testNG表示下一代. testNG是类似于 ...

  4. AFNetworking使用

    1.访问网络获取Json //Get方法 NSString *str = @"http://api.xxx.cc/product/found.jhtml"; NSDictionar ...

  5. ios绘图时的坐标处理

    在iOS中,进行绘图操作时,一般主要是在UIView:drawRect中调用 UIGraphicsBeginImageContextWithOptions等一系列函数,有时候直接画图就行,比如UIIm ...

  6. MTK6577+Android4.04编译

    MTK6577+Android4.04编译 编译命令 ./mk new 出错信息如下: **********checkingEnv************ Your building environm ...

  7. HDU 4633 Who's Aunt Zhang(polay计数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4633 题意:有下面一个魔方.有K种颜色.可以为顶点.边.面(每个面有9个小面)染色.两种染色算作一种当 ...

  8. 设置图片Alpha

    Drawable ico = getResources().getDrawable(R.drawable.search_box);                       mSearchLayou ...

  9. HDU 4870 Rating (2014 Multi-University Training Contest 1)

    Rating Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  10. LeetCode Invert Binary Tree 反转二叉树

    思路:递归解决,在返回root前保证该点的两个孩子已经互换了.注意可能给一个Null. C++ /** * Definition for a binary tree node. * struct Tr ...