F. The Weakest Sith----排序水题

来源:互联网 发布:windows 轻量级虚拟机 编辑:程序博客网 时间:2024/05/17 03:44

F. The Weakest Sith
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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: aibici (1 ≤ ai, bi, ci ≤ 109) — the three corresponding characteristics of the i-th Sith.

Output

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.

Examples
input
43 11 91 4 85 2 1012 7 6
output
12
input
3700 40 150 2 8003 900 60
output
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;}


0 0
原创粉丝点击