标签:pre code images head 没有 mission sep esc rect
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6094 | Accepted: 3639 |
Description
Input
Output
Sample Input
4 10 0 10 100 0 20 20 80 80 60 60 40 40 5 10 15 10 95 10 25 10 65 10 75 10 35 10 45 10 55 10 85 10 5 6 0 10 60 0 4 3 15 30 3 1 6 8 10 10 2 1 2 8 1 5 5 5 40 10 7 9 0
Sample Output
Box 2: 5 Box 1: 4 2: 1
Source
#include <set> #include <map> #include <queue> #include <stack> #include <math.h> #include <vector> #include <string> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <algorithm> #define zero(a) fabs(a)<eps #define max( x, y ) ( ((x) > (y)) ? (x) : (y) ) #define min( x, y ) ( ((x) < (y)) ? (x) : (y) ) #define lowbit(x) (x&(-x)) typedef long long ll; const double pi=acos(-1.0); const int inf=0x3f3f3f3f; const ll linf=0x3f3f3f3f3f3f3f3f; const int maxn = 5050; const double eps=1e-8; using namespace std; struct point { int x,y; point() {} point(int _x,int _y) { x = _x; y = _y; } point operator -(const point &b)const { return point(x - b.x,y - b.y); } //叉积 double operator ^(const point &b)const { return x*b.y - y*b.x; } //点积 double operator *(const point &b)const { return x*b.x + y*b.y; } //绕原点旋转角度B(弧度值),后x,y的变化 void transXY(double B) { double tx = x,ty = y; x = tx*cos(B) - ty*sin(B); y = tx*sin(B) + ty*cos(B); } }; struct Line { point s,e; Line() {} Line(point _s,point _e) { s = _s; e = _e; } }; Line line[maxn]; //int ans[maxn]; struct qw { int num,id; } ans[maxn]; int xmult(point p0,point p1,point p2) { return (p1-p0)^(p2-p0); } bool cmp1(Line a,Line b) { return a.s.x < b.s.x; } int cmp(qw x,qw y) { return x.num>y.num; } int main() { int n,m,x1,y1,x2,y2; while(~scanf("%d",&n)&&n) { scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2); for(int i=0;i<n;i++){ ans[i].id=i; ans[i].num=0; } int t1,t2; for(int i=0;i<n;i++){ scanf("%d%d",&t1,&t2); line[i]=Line(point(t1,y1),point(t2,y2)); } line[n]=Line(point(t2,y1),point(t2,y2)); sort(line, line+n+1, cmp1); // printf("test \n"); while(m--){ int x,y; point p; int tmp; scanf("%d%d",&x,&y); p=point(x,y); int l=0,r=n; while(l<=r){ int mid=(l+r)/2; if(xmult(p,line[mid].s,line[mid].e)<0){ tmp=mid; r=mid-1; } else l=mid+1; } ans[tmp].num++; } sort(ans,ans+n,cmp); printf("Box\n"); for(int i=0;i<n;i++){ if(ans[i].num!=0){ printf("%d: %d\n",ans[i].id,ans[i].num); } } } return 0; } /* 4 10 0 10 100 0 20 20 80 80 60 60 40 40 5 10 15 10 95 10 25 10 65 10 75 10 35 10 45 10 55 10 85 10 5 6 0 10 60 0 4 3 15 30 3 1 6 8 10 10 2 1 2 8 1 5 5 5 40 10 7 9 0 */
标签:pre code images head 没有 mission sep esc rect
原文地址:http://www.cnblogs.com/lalalatianlalu/p/7672631.html