Gym-101174B Bribing Eve (象限极角排序)
来源:互联网 发布:淘宝验证码 编辑:程序博客网 时间:2024/05/21 09:01
Bribing Eve
Eve works at a magazine that does product reviews and publishes
recommendations to consumers. They are working on a
new mobile phones review and have decided on two reproducible
tests that score each device's battery lifetime and performance
using an integer between 1 and 1000.
These two scores, x1 and x2, are then combined with a weights
vector w = [w1, w2] to produce an overall score:
s = w1x1 + w2x2 .
The nal review ranking is then obtained by sorting the products
by decreasing order of s. Additionally, when multiple products
get exactly the same score, Eve decides how to order them.
Maria (a fake name to mask her identity) tried to bribe Eve to tweak the results to get her
product higher on the list. Eve argued that she was not able to tamper the evaluation of each
test, but Maria suggested to tweak the weights w used when computing the overall score. The
weights w must be non-negative and at least one of them must be positive, but the values are
decided by Eve.
Eve is thinking whether to modify the weights in Maria's benet or not, and asked you to
determine what are the best and worst possible ranking positions for Maria's product.
Task
Given a list of all products scores in battery and performance [x1, x2] tests, nd out what are
the best and worst positions in the ranking that can be given to Maria's product when the
weights [w1, w2] and the order for tied products are left for Eve to decide.
Input
The rst line has the number N of products being compared. N lines follow, each containing
two integers x1 and x2 indicating a product's score in the battery and performance tests.
Maria's product is the rst on the list.
Constraints
1 ≤ N ≤ 100 000 Number of products
1 ≤ x1, x2 ≤ 1 000 Performance of a product in the tests
SWERC'2016 Universidade do Porto 5
Problem B Problem B
Output
The output consists of two numbers A and B, indicating the best and worst possible positions
that Maria's product can get on the ranking given Eve's ability to modify the weights and
ordering in case of a tie.
Sample Input
5
7 7
11 10
8 5
1 1
12 12
Sample Output
Eve works at a magazine that does product reviews and publishes
recommendations to consumers. They are working on a
new mobile phones review and have decided on two reproducible
tests that score each device's battery lifetime and performance
using an integer between 1 and 1000.
These two scores, x1 and x2, are then combined with a weights
vector w = [w1, w2] to produce an overall score:
s = w1x1 + w2x2 .
The nal review ranking is then obtained by sorting the products
by decreasing order of s. Additionally, when multiple products
get exactly the same score, Eve decides how to order them.
Maria (a fake name to mask her identity) tried to bribe Eve to tweak the results to get her
product higher on the list. Eve argued that she was not able to tamper the evaluation of each
test, but Maria suggested to tweak the weights w used when computing the overall score. The
weights w must be non-negative and at least one of them must be positive, but the values are
decided by Eve.
Eve is thinking whether to modify the weights in Maria's benet or not, and asked you to
determine what are the best and worst possible ranking positions for Maria's product.
Task
Given a list of all products scores in battery and performance [x1, x2] tests, nd out what are
the best and worst positions in the ranking that can be given to Maria's product when the
weights [w1, w2] and the order for tied products are left for Eve to decide.
Input
The rst line has the number N of products being compared. N lines follow, each containing
two integers x1 and x2 indicating a product's score in the battery and performance tests.
Maria's product is the rst on the list.
Constraints
1 ≤ N ≤ 100 000 Number of products
1 ≤ x1, x2 ≤ 1 000 Performance of a product in the tests
SWERC'2016 Universidade do Porto 5
Problem B Problem B
Output
The output consists of two numbers A and B, indicating the best and worst possible positions
that Maria's product can get on the ranking given Eve's ability to modify the weights and
ordering in case of a tie.
Sample Input
5
7 7
11 10
8 5
1 1
12 12
Sample Output
3 4
题解:考虑函数的几何意义,枚举向量,使用象限极角排序+二分查找,其实不用二分也可以。
#include <iostream>#include <bits/stdc++.h>using namespace std;const double eps=1e-9;struct point{ int x,y;}pp[100005];typedef point Vector;Vector vc[100005];int sum1=0,sum2=0,sum3=0,sum4=0;double dot(Vector a,Vector b){ return 1.0*a.x*b.y-1.0*a.y*b.x;}int quad(Vector a)// 判断象限的函数,每个象限包括半个坐标轴{ if( a.x>=0 && a.y>0 ) return 1; if( a.x<0 && a.y>=0 ) return 2; if( a.x<=0 && a.y<0 ) return 3; if( a.x>0 && a.y<=0 ) return 4;}bool operator < (const Vector &a,const Vector &b){ Vector p1 = a,p2 = b; int l1,l2; l1 = quad(p1); l2 = quad(p2); if( l1 == l2 ) { if(dot(a,b)>0) return true; else return false; } return l1 < l2;}int main(){ int n; cin>>n; int sum5=0; for(int i=0;i<n;i++) { scanf("%d %d",&pp[i].x,&pp[i].y); vc[i].x=pp[i].x-pp[0].x,vc[i].y=pp[i].y-pp[0].y; if(vc[i].x==0&&vc[i].y==0){ vc[i].x=vc[i].y=1; sum5++; } if(i==0) continue; if(vc[i].x>=0) sum1++; if(vc[i].x>0) sum2++; if(vc[i].y>=0) sum3++; if(vc[i].y>0) sum4++; } sort(vc+1,vc+n); /*for(int i=1;i<n;i++) cout<<vc[i].x<<' '<<vc[i].y<<endl;*/ int ans1=0,ans2=10000000; for(int i=1;i<n;i++) { if((vc[i].x<=0&&vc[i].y>=0)) { //cout<<i<<endl; Vector a; a.x=-1*vc[i].x,a.y=-1*vc[i].y; int c=lower_bound(vc+1,vc+n,a)-vc; int d=upper_bound(vc+1,vc+n,a)-vc; int now=i; if(c>=i)now+=n-1; else if(d>=i)now+=n-1; //cout<<c<<d<<endl; ans1=max((now-c+1)+1,ans1); ans2=min((now-d+1-sum5)+1,ans2); //cout<<c<<' '<<d<<' '<<i<<' '<<ans1<<' '<<ans2<<endl; } else continue; } ans1=max(ans1,sum1+1); ans1=max(ans1,sum3+1); ans2=min(ans2,sum2+1); ans2=min(ans2,sum4+1); cout<<ans2<<' '<<ans1<<endl; //cout << "Hello world!" << endl; return 0;}
阅读全文
0 0
- Gym-101174B Bribing Eve (象限极角排序)
- Codeforces Gym 101174 B. Bribing Eve
- GYM 100247 B. Similar Strings(水~)
- GYM 100030 B.Epic Battle(博弈论)
- GYM 100182 B.Euclid(计算几何)
- GYM 100883 B.Rectangles(水~)
- GYM 101147 B.Street(Floyd)
- GYM 100971 B.Derangement(水~)
- GYM 101086 B.Brother Louie(dfs)
- GYM 100694 B.Far Manager(水~)
- Gym-101201B(bfs+dp)
- Bribing FIPA(树形DP)
- Bribing FIPA (树形dp)
- 象限角和方位角
- HDU 5695 Gym Class(拓扑排序)
- hdu5695 Gym Class(拓扑排序+优先)
- Gym Class(优先队列+拓扑排序)
- Gym 100685F Flood(拓扑排序)
- linux 基础学习(基本命令等)
- 美素数
- 我对 React Native 的理解和看法
- Http协议与TCP协议简单理解
- JAVA题目汇总
- Gym-101174B Bribing Eve (象限极角排序)
- 导入导出为excel
- CBB电容代替电容的情况及两者区别
- sql server 2005 ssms 竟然没装上
- SDNU 51nod 几道简单的博弈题目
- 2011-2014,构建原子力显微镜的感悟
- Java泛型编程与多态、重载的同与不同
- 2.9 linux存储管理-页面的换入
- DX9鼠标拾取网格轨迹