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)项和都是正的,那么这个数列是正的,问这个 ...
随机推荐
- win32线程池代码(WinApi/C++)
win32线程池代码(WinApi/C++) 健壮, 高效,易用,易于扩, 可用于任何C++编译器 //说明, 这段代码我用了很久, 我删除了自动调整规模的代码(因为他还不成熟)/********** ...
- Intellj IDEA 启动参数调优
(修改前记得备份) 修改IntellJ/bin/idea.exe.vmoptions修改成 -Xms512m -Xmx512m -Xmn164m -XX:MaxPermSize=250m -XX:Re ...
- LDAP错误代码221
---------------------------命令方式启动失败报错-------------------------------[root@rusky bin]# ./dsadm start ...
- oracle之时间格式的应用
${,""," and rs.count_date >= '"+start_date+"'||' 00:00:00'")} ${,&q ...
- (四)《Java编程思想》——可变参数列表
以object数组为参数的方法实现可变参数列表 package chapter5; /** * 以object数组为参数的方法实现可变参数列表 */ class A { } public class ...
- C# 无边框窗体移动代码
C# 无边框窗体移动代码 Point _frmPoint = new Point(); //移动前窗体左上角坐标 Point _mousePoint = new Point(); //按下鼠标时坐标 ...
- SqlServer跨域查询
SELECT * FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.1.14;User ID=sa;Password=sql.com').eBui ...
- UITableVIewcell中图片不能改变大小的原因
你有没没有发现,有时候把图片放进cell.imageView中时无法顺利改变大小呢? 其实根本原因是要在layoutSubviews重新配置一下,cell的布局里面默认有一个imageiView,同时 ...
- 更换ios 开发者账号与下载别人的代码 真机调试时注意切换
Buid Setting search sign
- JavaScript加密解密压缩工具
<script> a=62; function encode() { var code = document.getElementById('code').value; code = co ...