GYM 100247 A. The Power of the Dark Side(水~)
来源:互联网 发布:机构投资者持股数据 编辑:程序博客网 时间:2024/05/01 11:07
Description
n名队员,每个人有三种能力a[i],b[i],c[i],一个人打败另一个人当且仅当其至少有两种能力强于对方,现在可以将任一个人的任两种能力值互换,问有多少人可以打败其他所有人
Input
第一行一整数n表示人数,之后n行每行三个整数a[i],b[i],c[i]表示第i个人的三种能力值,保证所有能力值都不同
(1<=n<=200000,1<=a[i],b[i],c[i]<=1e9)
Output
输出满足条件的人数及其编号
Sample Input
4
5 9 10
2 12 4
8 7 3
6 11 1
Sample Output
2
1 4
Solution
对所有人的三种能力排序,更新前两种能力的最大值和次大值,那么如果一个人的后两种能力值分别大于其他人前两种能力的最大值(这个人的前两种能力可能是最大值,所以还要记录次大值),那么这个人满足条件
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 222222int n,a[maxn][3],Max[3],Smax[3],res,ans[maxn]; int main(){ while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) for(int j=1;j<=3;j++) scanf("%d",&a[i][j]); for(int i=1;i<=n;i++)sort(a[i]+1,a[i]+4); if(n==1) { printf("1\n1\n"); continue; } for(int i=1;i<=3;i++)Max[i]=a[1][i],Smax[i]=a[2][i]; for(int i=1;i<=n;i++) for(int j=1;j<=3;j++) { if(a[i][j]>Smax[j])Smax[j]=a[i][j]; if(Smax[j]>Max[j])swap(Max[j],Smax[j]); } res=0; for(int i=1;i<=n;i++) { int t1=Max[1],t2=Max[2]; if(a[i][1]==Max[1])t1=Smax[1]; if(a[i][2]==Max[2])t2=Smax[2]; if(a[i][2]>t1&&a[i][3]>t2)ans[++res]=i; } printf("%d\n",res); for(int i=1;i<=res;i++) printf("%d%c",ans[i],i==res?'\n':' '); } return 0;}
0 0
- GYM 100247 A. The Power of the Dark Side(水~)
- A Tale from the Dark Side of The Moon
- A Tale from the Dark Side of The Moon
- POJ 3510 A Tale from the Dark Side of the Moon (读题死)
- POJ 3510 A Tale from the Dark Side of the Moon 可能会
- POJ_3510_A Tale from the Dark Side of the Moon
- Java 8 Friday: The Dark Side of Java 8
- A dark variant of the 'Cranefly' theme
- 【再看细节】SDUT春季高校周赛9 Problem E——A Tale from the Dark Side of The Moon
- GYM 101147 A.The game of Osho(博弈论)
- Fear of the Dark @ JDJ
- The woman was made of a rib out of the side of man...
- The Other Side of Diversity
- GYM 100712 A.Who Is The Winner?(水~)
- The power of Reading
- The power of algorithm
- The Power of Imagination
- power of the test
- c++第二次实验:输出完数
- Spring AOP 实现原理
- 【HDU 1431】素数回文
- python,Cocos2d-x,关于配置python后出现的问题,导致命令行失效,
- LAMP服务器优化---Nginx
- GYM 100247 A. The Power of the Dark Side(水~)
- Spring AOP
- [IOS APP]曾仕强演说精选-有声系列
- HDU 3652 B-number
- 数据库事务四种隔离级别
- spring 的platformTrasactionoManager API讲解(翻译)
- 一天一个LINUX命令教程[4]-chmod命令
- 树的广度优先遍历(非递归)和深度优先遍历
- Linux SVN命令详解