F. The Weakest Sith----排序水题
来源:互联网 发布:windows 轻量级虚拟机 编辑:程序博客网 时间:2024/05/17 03:44
In a galaxy far, far away the great galactic empire had collapsed after the death of the emperor, and now a new corrupted galactic republic gradually grows stronger. But the evil Sith don't spend time in vain: they've created opposition named «The last order» and now they are planning to choose a leader by a fair tournament.
In the tournament there will be n Siths who has left alive. The i-th of these Siths has three integer characteristics: mastery of lightsabers ai, mastery of the Force bi and the level of mental balance ci. All characteristics of all Siths are different. The tournament consists of one on one fights. The winner of each of these fights is the Sith who has at least two characteristics that are bigger than their opponent's corresponding ones.
The problem is that the Sith tournaments have never been organized to find the strongest Sith who could beat anyone else: instead, they were supposed to distinguish the weakest one, somebody who couldn't win any fight, and to let everybody take a good laugh at that loser. It seems like such Sith will become the leader of «The last order», so it'd be good to know them in advance.
The first line contains a single integer n (2 ≤ n ≤ 2·105) — the number of the Siths who will participate in the tournament.
Each of the next n lines contains three space-separated integers: ai, bi, ci (1 ≤ ai, bi, ci ≤ 109) — the three corresponding characteristics of the i-th Sith.
In the first line output a single integer — the number of Siths who can't win any fight.
In the second line print the numbers of those Siths separated by a space.
43 11 91 4 85 2 1012 7 6
12
3700 40 150 2 8003 900 60
0
题目链接:http://codeforces.com/gym/101149/problem/F
每个人有三个值,各不相同,两两PK ,两个值大的人获胜,不会出现平局,求输掉所有局的人。
排序水一下就好了。
代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define LL long longusing namespace std;struct node{LL a,b,c,id;}xin[300000];bool cmp(struct node a,struct node b){int ans=0;if(a.a>b.a)ans++;if(a.b>b.b)ans++;if(a.c>b.c)ans++;if(ans<2)return false; return true;}bool judge(struct node a,struct node b){ int ans=0;if(a.a>b.a)ans++;if(a.b>b.b)ans++;if(a.c>b.c)ans++;if(ans<2)return false; return true;}int main(){int n;while(~scanf("%d",&n)){ for(int i=0;i<n;i++){ scanf("%lld%lld%lld",&xin[i].a,&xin[i].b,&xin[i].c); xin[i].id=i+1; } sort(xin,xin+n,cmp); struct node t=xin[n-1]; bool flag=true; for(int i=0;i<n-1;i++){ if(judge(t,xin[i])){ flag=false; break; } } if(flag){ cout<<1<<endl; printf("%lld\n",xin[n-1].id); } else{ printf("0\n"); }}return 0;}
- F. The Weakest Sith----排序水题
- GYM 101149 F.The Weakest Sith(水~)
- Gym 101149FThe Weakest Sith
- F. Avoid The Lakes
- 数学F - The Snail
- F - Count the Colors
- F. Set the memory
- bnu10.7弱校F题 Snipe the Sniper
- cf678E. Another Sith Tournament
- Another Sith Tournament
- F**K the struts helloworld
- The history 0f Borland
- Lua:The Frontier pattern: %f
- convert the C to F
- but nothing on the f
- F-secure Protecting the Irrepplacable
- F - The MAX(sort)
- the f..king Great Wall
- Undefined symbols for architecture i386 libGCloudVoice.a _GetVoiceEngine
- 安装mysql5.7.19
- C++ 控制台程序 如何使用 CString类
- 图片转字符画
- Java 学习——Map
- F. The Weakest Sith----排序水题
- SQL高级查询
- TCP-IP协议栈总结、can资料网址
- jboss vfsfile ClassNotFoundException解决办法
- 天梯赛练习 天梯地图(SPFA)
- C++习题Complex Number(Eden)
- Markdown使用其二
- C++_重载、重写和重定义的区别
- SQL查询学生信息表中的学生记录