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)项和都是正的,那么这个数列是正的,问这个 ...
随机推荐
- POJ 2502 Subway(迪杰斯特拉)
Subway Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6692 Accepted: 2177 Descriptio ...
- 如何解决svn图标不显示呢?
svn图标不显示解决 确保设置正确: 右键->TortoiseSVN->setting->Icon Overlays->Status cache->default/She ...
- mongo export import
mongoexport -h 127.0.0.1 -p 27170 -d dbs -c table -f field1,field2,field3 -q condition 路径.名称 mongoim ...
- mysql数据库的高可用方法总结
高可用架构对于互联网服务基本是标配,无论是应用服务还是数据库服务都需要做到高可用.虽然互联网服务号称7*24小时不间断服务,但多多少少有一 些时候服务不可用,比如某些时候网页打不开,百度不能搜索或者无 ...
- python 下的数据结构与算法---1:让一切从无关开始
这段时间把<Data Structure and Algorithms with python>以及<Problem Solving with Algorithms and Dat ...
- Linux下修改字符集,转自
以下转自http://blog.csdn.net/cyuyan112233/article/details/6539122 Linux下修改字符集 locale -a 查询系统支持的字符集 expor ...
- (五)backbone - DEMO - 通信录改造之使用requirejs
DEMO介绍是 DEMO通信录的扩展,使用requirejs模块化整合 大体实现 • model文件 model/contact.js define(function (){ // user cont ...
- MySql不支持事务解决
用的是一个绿色版的mysql数据库,发现不支持事务,在网络上搜集资料找到解决方案: 1.执行语句 SHOW ENGINES; 如果发现InnoDB全部显示为“YES”,说明该版本的数据库支持事务 2 ...
- vmware安装Linux时无法打开xpdf
vmware10+redhat9 在装第二张镜像文件时,出现如下提示:无法打开xpdf-2.01-8软件包...... 解决方法: vmware中,虚拟机->设置->硬件->CD/D ...
- Asp.Net 控件radio 的简单使用
js: <script type="text/javascript"> function ok() { document.getElementById("tx ...