hdu 4946 2014 Multi-University Training Contest 8
2014-10-20 13:01
453 查看
Area of Mushroom
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2390 Accepted Submission(s): 578
[align=left]Problem Description[/align]
Teacher Mai has a kingdom with the infinite area.
He has n students guarding the kingdom.
The i-th student stands at the position (xi,yi), and his walking speed is vi.
If a point can be reached by a student, and the time this student walking to this point is strictly less than other students, this point is in the charge of this student.
For every student, Teacher Mai wants to know if the area in the charge of him is infinite.
[align=left]Input[/align]
There are multiple test cases, terminated by a line "0".
For each test case, the first line contains one integer n(1<=n<=500).
In following n lines, each line contains three integers xi,yi,vi(0<=|xi|,|yi|,vi<=10^4).
[align=left]Output[/align]
For each case, output "Case #k: s", where k is the case number counting from 1, and s is a string consisting of n character. If the area in the charge of the i-th student isn't infinite, the i-th character is "0", else it's "1".
[align=left]Sample Input[/align]
3
0 0 3
1 1 2
2 2 1
0
[align=left]Sample Output[/align]
Case #1: 100
[align=left]Author[/align]
xudyh
[align=left]Source[/align]
2014 Multi-University Training Contest 8
简单凸包,但是!!调了好久!
首先凸包边上的点时可以算的,所以我算的两向量相乘等于0是可以加进去的,但是点有重复啊!所以两个点重复的时候会怎样?乘前面后面的都为0,即使后面的向量加进去之后是凹的。。所以必须判断下一个点是不是和前一个点重合,重合则删去,然后最后把有被重复的再删去。
#include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<map> #include<algorithm> #define M(a,b) memset(a,b,sizeof(a)) using namespace std; int n; struct Node { long long x,y; int num; int flag; int speed; Node(int x=0, int y=0):x(x),y(y){} bool operator < (const Node &rhs) const { if(x==rhs.x) return y<rhs.y; return x<rhs.x; } }; int ans[506]; long long cross(Node A, Node B) {return A.x*B.y-A.y*B.x;} typedef Node Vector; Vector operator+(Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);} Vector operator-(Node A,Node B){return Vector(A.x-B.x,A.y-B.y);} Vector operator*(Vector A,int p){return Vector(A.x*p,A.y*p);} Vector operator/(Vector A,int p){return Vector(A.x/p,A.y/p);} int tubao(Node* poin,int cn,Node* che) { sort(poin,poin+cn); int m = 0; for(int i = 0;i<cn;i++) { while(m>1&&(cross(che[m-1]-che[m-2],poin[i]-che[m-1])<0||(poin[i].x==che[m-1].x&&poin[i].y==che[m-1].y))) { //cout<<cross(che[m-1]-che[m-2],poin[i]-che[m-1])<<' '<<i<<'i'<<' '<<m<<'m'<<'!'<<endl; m--; }//cout<<cross(che[m-1]-che[m-2],poin[i]-che[m-1])<<' '<<i<<'i'<<' '<<m<<'m'<<endl; che[m++] = poin[i]; //for(int i = 0;i<m;i++) //cout<<che[i].x<<' '<<che[i].y<<endl; //cout<<endl; } int k = m; for(int i = cn-2; i>=0 ;i--) { while(m>k&&(cross(che[m-1]-che[m-2],poin[i]-che[m-1])<0||(poin[i].x==che[m-1].x&&poin[i].y==che[m-1].y))) m--; che[m++] = poin[i]; } if(cn>1) m--; return m; } int main() { int cas = 0; while(scanf("%d",&n)==1&&n!=0) { Node point[506],point1[506],ch[506]; cas++; M(ans,0); int a; long long b,c; int maxv = -1; for(int i = 0;i<n;i++) { scanf("%I64d%I64d%d",&b,&c,&a); point[i].x = b; point[i].y = c; point[i].num = i; point[i].speed = a; point[i].flag = 0; if(a>maxv) maxv = a; } int cnt = 0; for(int i = 0;i<n;i++) { if(point[i].speed==maxv) { point1[cnt] = point[i]; cnt++; } } sort(point1,point1+cnt); for(int i = 0;i<cnt-1;i++) { if(point1[i].x==point1[i+1].x&&point1[i].y==point1[i+1].y) point1[i].flag = 1,point1[i+1].flag = 1; } int temm = tubao(point1,cnt,ch); for(int i = 0;i<temm;i++) { if(maxv==0) break; //cout<<ch[i].x<<' '<<ch[i].y<<'!'<<endl; if(ch[i].flag==0) ans[ch[i].num] = 1; } printf("Case #%d: ",cas); for(int i = 0;i<n;i++) { printf("%d",ans[i]); } printf("\n"); } return 0; }
相关文章推荐
- HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
- 【2014 Multi-University Training Contest 3 1007】/【HDU 4893】 Wow! Such Sequence!
- hdu 4962 Closed Paths 计算几何 2014 Multi-University Training Contest 9-1003
- hdu 4967 Handling the Past 线段树 2014 Multi-University Training Contest 9-1008
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- hdu 4927 Series 1--2014 Multi-University Training Contest 6
- hdu 4939 2014 Multi-University Training Contest 7 1005
- hdu 4920 Matrix multiplication 2014 Multi-University Training Contest 5
- HDU 4906 Our happy ending(2014 Multi-University Training Contest 4)
- HDU 4899 Hero meet devil(状压DP)(2014 Multi-University Training Contest 4)
- hdu 4864 Task 2014 Multi-University Training Contest 1
- HDU 4951 Multiplication table(2014 Multi-University Training Contest 8)
- hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6
- hdu 4965 Fast Matrix Calculation 矩阵 2014 Multi-University Training Contest 9-1006
- hdu 4941 Magical Forest 2014 Multi-University Training Contest 7
- 【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection
- HDU 4888 Redraw Beautiful Drawings(2014 Multi-University Training Contest 3)
- hdu 4961 Boring Sum(2014 Multi-University Training Contest 9)
- hdu 4968 Just a Joke 数学(积分) 2014 Multi-University Training Contest 9-1010
- hdu 4947 A simple dynamic programming problem(2014 Multi-University Training Contest 10)