Episode N-th: The Jedi Tournament

Time limit: 1.0 second
Memory limit: 64 MB
Decided several Jedi Knights to organize a tournament once. To know, accumulates who the largest amount of Force. Brought each Jedi his lightsaber with him to the tournament. Are different the lightsaber, and Jedi different are. Three parameters there are: length of the saber, Force of the Jedi and how good the Light side of the Force the Jedi can use. If in at least two parameters one Jedi than the other one stronger is, wins he. Is not possible a draw, because no Jedi any equal parameter may have. If looses a Jedi, must leave the tournament he.
To determine, which Jedi the tournament can win, your program is. Can win the tournament a Jedi, if at least one schedule for the tournament possible is, when the last one remains he on the tournament, not looses any match. For example, if Anakin stronger than Luke by some two parameters is, and Luke stronger than Yoda by some two parameters is, and Yoda stronger than Anakin, exists in this case a schedule for every Jedi to win the tournament.

Input

In the first line there is a positive integer N ≤ 200, the total number of Jedi. After that follow N lines, each line containing the name of the Jedi and three parameters (length of the lightsaber, Force, Light side in this order) separated with a space. The parameters are different integers, not greater than 100000 by the absolute value. All names are sequences of not more than 30 small and capital letters.

Output

Your program is to output the names of those Jedi, which have a possibility to win the tournament. Each name of the possible winner should be written in a separate line. The order of the names in the output should correspond to the order of their appearance in the input data.

Sample

input output
5
Solo 0 0 0
Anakin 20 18 30
Luke 40 12 25
Kenobi 15 3 2
Yoda 35 9 125
Anakin
Luke
Yoda
Problem Author: Leonid Volkov
【分析】绝地大师比武,每个绝地大师有三个参数,设为a,b,c;对于两个绝地大师甲和乙,如果甲有两个参数大于乙,则甲能打过乙,如果对于三个人甲乙丙,若甲能打过乙,乙能打过丙,丙能打过甲,且无其他人打得过他们,则他们三都第一。现在给你一些绝地大师的姓名及参数,让你找第一。
       做法就是强连通分量缩点,每个强连通分量里的点都是同一排名不分上下的,现在就是找缩点后入度为零的点。
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof a)
#define pb push_back
typedef long long ll;
using namespace std;
const int N = ;
const int M = +;
int n,m,k,s,t,tot,cut=,tim=,top=;
int head[N],vis[N],dis[N];
int dfn[N],low[N],stack1[N],num[N],in[N],out[N];
struct node{
string s;int a,b,c;
}no[N];
struct man{
int to,next;
}edg[M];
void add(int u,int v){
edg[tot].to=v;edg[tot].next=head[u];head[u]=tot++;
}
int charge(int x,int y){
if(x>y)return ;else return ;
}
void Tarjan(int u){
int v;
low[u] = dfn[u] = ++tim;
stack1[top++] = u;
vis[u] = ;
for(int e = head[u]; e != -; e = edg[e].next){
v = edg[e].to;
if(!dfn[v]){
Tarjan(v);
low[u] = min(low[u], low[v]);
}
else if(vis[v]){
low[u] = min(low[u], dfn[v]);
}
}
if(low[u] == dfn[u]){
cut++;
do
{
v = stack1[--top];
num[v] = cut;
vis[v] = ;
}while(u != v);
}
}
int main() {
int u,v,val;tot=;met(dfn,);met(vis,);met(head,-);
scanf("%d",&n);
string str;
for(int i=;i<=n;i++){
cin>>no[i].s>>no[i].a>>no[i].b>>no[i].c;
}
for(int i=;i<=n;i++){
for(int j=;j<=n;j++){
if(charge(no[i].a,no[j].a)+charge(no[i].b,no[j].b)+charge(no[i].c,no[j].c)>=){
add(i,j);
}
}
}
for(int i=;i<=n;i++)if(!dfn[i])Tarjan(i);
for(int i=;i<=n;i++){
for(int j=head[i];j!=-;j=edg[j].next){
int v=edg[j].to;
if(num[i]!=num[v])out[num[i]]++,in[num[v]]++;
}
}
int father;
for(int i=;i<=cut;i++){
if(!in[i]){father=i;break;}
}
for(int i=;i<=n;i++){
if(num[i]==father){
cout<<no[i].s<<endl;
}
}
return ;
}

URAL 1218 Episode N-th: The Jedi Tournament(强连通分量)(缩点)的更多相关文章

  1. ural 1218. Episode N-th: The Jedi Tournament

    1218. Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Je ...

  2. 1218. Episode N-th: The Jedi Tournament(bfs)

    1218 简答题 对于当前点 判断每个点是否可达 #include <iostream> #include<cstdio> #include<cstring> #i ...

  3. 【CF878C】Tournament set+并查集+链表

    [CF878C]Tournament 题意:有k个项目,n个运动员,第i个运动员的第j个项目的能力值为aij.一场比赛可以通过如下方式进行: 每次选出2个人和一个项目,该项目能力值高者获胜,败者被淘汰 ...

  4. 【CF913F】Strongly Connected Tournament 概率神题

    [CF913F]Strongly Connected Tournament 题意:有n个人进行如下锦标赛: 1.所有人都和所有其他的人进行一场比赛,其中标号为i的人打赢标号为j的人(i<j)的概 ...

  5. 【CodeForces】913 F. Strongly Connected Tournament 概率和期望DP

    [题目]F. Strongly Connected Tournament [题意]给定n个点(游戏者),每轮游戏进行下列操作: 1.每对游戏者i和j(i<j)进行一场游戏,有p的概率i赢j(反之 ...

  6. Google Interview University - 坚持完成这套学习手册,你就可以去 Google 面试了

    作者:Glowin链接:https://zhuanlan.zhihu.com/p/22881223来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 原文地址:Google ...

  7. 2011 ACM-ICPC 成都赛区解题报告(转)

    2011 ACM-ICPC 成都赛区解题报告 首先对F题出了陈题表示万分抱歉,我们都没注意到在2009哈尔滨赛区曾出过一模一样的题.其他的话,这套题还是非常不错的,除C之外的9道题都有队伍AC,最终冠 ...

  8. BZOJ ac100题存档

    不知不觉AC100题了,放眼望去好像都是水题.在这里就做一个存档吧(特别感谢各位大神尤其是云神http://hi.baidu.com/greencloud和丽洁姐http://wjmzbmr.com/ ...

  9. NEERC-2017

    A. Archery Tournament 用线段树套set维护横坐标区间内的所有圆,查询时在$O(\log n)$个set中二分查找即可. 时间复杂度$O(n\log^2n)$. #include& ...

随机推荐

  1. CSS 水平居中

    一.水平居中:行内元素解决方案 居中元素:文字.链接以及其它行内元素(inline或inline-*类型的元素,如inline-block,inline-table,inline-flex)解决方案: ...

  2. MyEclipse8.5集成Tomcat7

    我最近需要在MyEclipse中使用Tomcat7,已经在Servers中配置了本地的Tomcat路径,之后发布项,在MyEclipse启动Tomcat服务则出现如下错误提示: Exception i ...

  3. Android 之 数据存储

    在Android操作系统中,提供了5种数据存储方式:SharedPreferences存储,文件存储,SQLite数据库存储,ContentProvider存储和网络存储. 一.SharedPrefe ...

  4. 关于Xcode调试的帖子,感觉不错,转来看看

    http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 http://www.raywenderlich.com/10505 ...

  5. cf--1C

    //Accepted 0 KB 60 ms //给出正多变形上的三个点,求正多形的最小面积 //记三个点之间的距离a,b,c; //由余弦定理得cosA //从而可求出sinA,和正多边形所在外接圆的 ...

  6. POJ 3156 - Interconnect (概率DP+hash)

    题意:给一个图,有些点之间已经连边,现在给每对点之间加边的概率是相同的,问使得整个图连通,加边条数的期望是多少. 此题可以用概率DP+并查集+hash来做. 用dp(i,j,k...)表示当前的每个联 ...

  7. (转)JS中innerHTML,innerText,value

    原文:http://holysonll.blog.163.com/blog/static/21413909320134111054352/ JS中innerHTML,innerText,value 2 ...

  8. 2016-1-15 抽屉效果实现demo

    // // ViewController.m // 抽屉 // // Created by Mac on 16/1/15. // Copyright © 2016年 Mac. All rights r ...

  9. 2016-1-7第一个完整APP 私人通讯录的实现 5:保存数据

    一:登陆界面 1):用户点击登陆按钮并成功登陆后,根据此时的开关情况选择是否保存数据,代码如下: "]) { [self performSegueWithIdentifier:@" ...

  10. ABBYY

    ABBYY FineReader Engine泰比OCR文字识别控件移动版 产品功能:OMR识别控件 平台: 开发商:ABBYY泰比科技 版本:产品介绍:手机识别的高品质和精度 泰比( ...