FZU-1925+几何
题意简单。
由于没有注意到椭圆不一定是在圆心。。贡献无数的wa。。。。。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std; const int maxn = 555;
const int maxm = 555;
const double eps = 1e-8; struct Node{
char name[55];
char nation[55];
int sum;
int id;
double x,y;
}p[ maxn ]; struct Cir{
double r;
double x,y;
int val;
}c1[ maxm ];
struct Cir2{
double x,y;
double a,b;
int val;
}c2[ maxm ];
struct Point {
double x,y;
};
struct Ploy{
Point pnt[ maxn ];
int cnt;
int val;
}ploy[ maxm ]; int od[ maxm ]; int cmp( Node a,Node b ){
if( a.sum!=b.sum ) return a.sum>b.sum;
else return a.id<b.id;
} double dis( double x1,double y1,double x2,double y2 ){
return ( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
} bool InCir( Node aim,int ID ){
double dd = dis( aim.x,aim.y,c1[ID].x,c1[ID].y );
if( dd<=c1[ID].r*c1[ID].r ) return true;
else return false;
} bool InCir2( Node aim,int ID ){
double dd = (aim.x-c2[ID].x)*(aim.x-c2[ID].x)/(c2[ID].a*c2[ID].a)+(aim.y-c2[ID].y)*(aim.y-c2[ID].y)/(c2[ID].b*c2[ID].b);
if( dd<=1.0 ) return true;
else return false;
} int D( double x ){
return x<-eps?-1:x>eps;
} double det( Point a,Point b,Point c ){
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
} int InPloy1( int n,double xx,double yy,Point pnt[] ){
Point q;
q.x = xx,q.y = yy;
int i,s[3] = {1,1,1};
pnt[n] = pnt[0];
for( int i=0;i<n&&s[0]|s[2];i++ ){
s[ D(det(pnt[i],pnt[i+1],q))+1 ] = 0;
}
return s[0]|s[2];
}
int InPloy2( int n,double xx,double yy,Point pnt[] ){
Point q;
q.x = xx;
q.y = yy;
int i,s[3] = {1,1,1};
pnt[n] = pnt[0];
for( int i=0;i<n&&s[1]&&s[0]|s[2];i++ ){
s[ D(det(pnt[i],pnt[i+1],q))+1 ] = 0;
}
return s[1]&&s[0]|s[2];
} void init(){
for( int i=0;i<maxn;i++ )
p[i].sum = 0;
} void test( int n ){
for( int i=1;i<=n;i++ ){
printf("name = %s, sum = %d\n",p[i].name,p[i].sum);
}
} int main(){
int T;
scanf("%d",&T);
int Case = 1;
while( T-- ){
int n,m;
scanf("%d",&m);
init();
char str[ 55 ];
for( int i=1;i<=m;i++ ){
scanf("%s",str);
if( str[0]=='C' ){
od[ i ] = 1;
scanf("%lf%lf%lf%d",&c1[ i ].x,&c1[ i ].y,&c1[ i ].r,&c1[ i ].val);
}
else if( str[0]=='E' ){
od[ i ] = 2;
scanf("%lf%lf%lf%lf%d",&c2[ i ].x,&c2[ i ].y,&c2[ i ].a,&c2[ i ].b,&c2[ i ].val);
}
else {
od[ i ] = 3;
int cc;
scanf("%d",&cc);
for( int j=0;j<cc;j++ ){
scanf("%lf%lf",&ploy[i].pnt[j].x,&ploy[i].pnt[j].y);
}
ploy[i].cnt = cc;
scanf("%d",&ploy[i].val);
}
}
scanf("%d",&n);
for( int i=1;i<=n;i++ ){
scanf("%s%s%lf%lf",p[i].name,p[i].nation,&p[i].x,&p[i].y);
//p[i].sum = 0;
p[i].id = i;
}
for( int i=1;i<=n;i++ ){
for( int j=1;j<=m;j++ ){
if( od[j]==1&&InCir( p[i],j )==true ){
p[i].sum += c1[j].val;
}
else if( od[j]==2&&InCir2( p[i],j )==true ){
p[i].sum += c2[j].val;
}
else if( od[j]==3&&(InPloy1( ploy[j].cnt,p[i].x,p[i].y,ploy[j].pnt )||InPloy2( ploy[j].cnt,p[i].x,p[i].y,ploy[j].pnt )) ){
p[i].sum += ploy[j].val;
}
}
} sort( p+1,p+1+n,cmp );
//test( n );
printf("Case %d:\n",Case ++ );
int Gold = 0;
if( p[1].sum<=0 ) continue;
int flag = 1;
for( int i=1;i<=n;i++ ){
if( p[i].sum==p[1].sum&&p[1].sum>0 ){
printf("Gold Medal: %s from %s got %d point(s)\n",p[i].name,p[i].nation,p[i].sum);
Gold ++ ;
flag = i;
}
else break;
}
if( p[flag+1].sum<=0 ) continue;
if( Gold>=3 ) continue;
int Silver = 0;
int temp = flag+1;
bool f = false;
for( int i=temp;i<=n;i++ ){
if( p[i].sum==p[temp].sum && p[i].sum>0 ){
flag = i;
Silver ++ ;
if( Gold<=1 ) printf("Silver Medal: %s from %s got %d point(s)\n",p[i].name,p[i].nation,p[i].sum);
else{
f = true;
printf("Bronze Medal: %s from %s got %d point(s)\n",p[i].name,p[i].nation,p[i].sum);
}
}
else break;
}
if( Silver+Gold>=3||f==true ) continue;
if( p[flag+1].sum<=0 ) continue;
for( int i=flag+1;i<=n;i++ ){
if( p[i].sum==p[flag+1].sum&&p[i].sum>0 ){
printf("Bronze Medal: %s from %s got %d point(s)\n",p[i].name,p[i].nation,p[i].sum);
}
else break;
}
}
return 0;
}
FZU-1925+几何的更多相关文章
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- fzu 2035 Axial symmetry(枚举+几何)
题目链接:fzu 2035 Axial symmetry 题目大意:给出n个点,表示n边形的n个顶点,判断该n边形是否为轴对称图形.(给出点按照图形的顺时针或逆时针给出. 解题思路:将相邻两个点的中点 ...
- FZU 2140 Forever 0.5 (几何构造)
Forever 0.5 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- FZU Moon Game(几何)
Accept: 710 Submit: 2038 Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Fa ...
- FZU 2140 Forever 0.5(找规律,几何)
Problem 2140 Forever 0.5 Accept: 371 Submit: 1307 Special Judge Time Limit: 1000 mSec Memory Limit : ...
- fzu 1015 土地划分(判断线段相交+求出交点+找规律)
链接:http://acm.fzu.edu.cn/problem.php?pid=1015 Problem 1015 土地划分 Accept: 714 Submit: 1675Time Lim ...
- 关于Three.js基本几何形状之SphereGeometry球体学习
一.有关球体SphereGeometry构造函数参数说明 <1>.SphereGeometry(radius, widthSegments, heightSegments, phiStar ...
- FZU 2137 奇异字符串 后缀树组+RMQ
题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...
- FZU 1914 单调队列
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...
随机推荐
- VMware上实现LVS负载均衡(NAT)
本文LVS的实现方式採用NAT模式.关于NAT的拓扑图请參照我的上一篇文章.本文纯粹实验.NAT在生产环境中不推荐使用.原因是Load Balancereasy成为瓶颈! 1.VMware9上安装Ce ...
- Java 动态代理机制详解(JDK 和CGLIB,Javassist,ASM)
class文件简介及加载 Java编译器编译好Java文件之后,产生.class 文件在磁盘中.这种class文件是二进制文件,内容是只有JVM虚拟机能够识别的机器码.JVM虚拟机读取字节码文件,取出 ...
- USB挂起与唤醒.
USB可见设备状态分为连接(Attached),上电(Powered),默认(Default),地址(Address),配置(Configured)和挂起(Suspended)6个状态.所谓可见,即U ...
- NPM与调试工具的使用
1)NPM 2)nodemon 自动监视文件的变化并重启应用 3)pm2 启动node,资源共享 4)node-inspector node调试工具 5)Chrome Developer Tools
- Sass运算
加法在 CSS 中能做运算的,到目前为止仅有 calc() 函数可行.在 Sass 中,运算只是其基本特性之一.在 Sass 中可以做各种数学计算.加法运算是 Sass 中运算中的一种,在变量或属性中 ...
- Android WifiDirect 学习(三) 一些基础知识和问题
P2P架构介绍 P2P架构中定义了三个组件,一个设备,两种角色.这三个组件分别是: P2P Device:它是P2P架构中角色的实体,读者可把它当做一个Wi-Fi设备. P2P Group Owner ...
- php多文本框提交
<form action="" method="post"><input type=text name=name[]><input ...
- Cookie 添加,读取,删除
Name,value – 声明时 new Cookie(key,value); Path - 默认值,即为当前保存cookie的这个serlvet所在的路径. 如果Cookie在这样的路 ...
- poj1611 简单并查集
The Suspects Time Limit: 1000MS Memory Limit: 20000K Total Submissions: 32781 Accepted: 15902 De ...
- SQL GROUP BY 语句
合计函数 (比如 SUM) 常常需要添加 GROUP BY 语句. GROUP BY 语句 GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 语法 ...