ural 1218. Episode N-th: The Jedi Tournament

1218. 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 followN 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
Problem Source: The Seventh Ural State University collegiate programming contest

Tags: graph theory  (hide tags for unsolved problems)

Difficulty: 338

题意:给出n个人,每个人有三个属性,一个人A比另一个人B优当且仅当A有至少两种属性不小于B的这两种属性,不存在两个人平局。问谁可能笑到最后?

注意,A优于B,B优于C,但C也可能优于A,此时A、B、C都可能笑到最后。

分析:就是说给出n个点,让你建出很多有向边I,j代表i优于j,最后问有多少点能访问全部点

floyd就好

  1 #include <cstdio>
  2 #include <cstring>
  3 #include <cstdlib>
  4 #include <cmath>
  5 #include <deque>
  6 #include <vector>
  7 #include <queue>
  8 #include <iostream>
  9 #include <algorithm>
 10 #include <map>
 11 #include <set>
 12 #include <ctime>
 13 using namespace std;
 14 typedef long long LL;
 15 typedef double DB;
 16 #define For(i, s, t) for(int i = (s); i <= (t); i++)
 17 #define Ford(i, s, t) for(int i = (s); i >= (t); i--)
 18 #define Rep(i, t) for(int i = (0); i < (t); i++)
 19 #define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
 20 #define rep(i, x, t) for(int i = (x); i < (t); i++)
 21 #define MIT (2147483647)
 22 #define INF (1000000001)
 23 #define MLL (1000000000000000001LL)
 24 #define sz(x) ((int) (x).size())
 25 #define clr(x, y) memset(x, y, sizeof(x))
 26 #define puf push_front
 27 #define pub push_back
 28 #define pof pop_front
 29 #define pob pop_back
 30 #define ft first
 31 #define sd second
 32 #define mk make_pair
 33 inline void SetIO(string Name) {
 34     string Input = Name+".in",
 35     Output = Name+".out";
 36     freopen(Input.c_str(), "r", stdin),
 37     freopen(Output.c_str(), "w", stdout);
 38 }
 39
 40 inline int Getint() {
 41     int Ret = 0;
 42     char Ch = ‘ ‘;
 43     while(!(Ch >= ‘0‘ && Ch <= ‘9‘)) Ch = getchar();
 44     while(Ch >= ‘0‘ && Ch <= ‘9‘) {
 45         Ret = Ret*10+Ch-‘0‘;
 46         Ch = getchar();
 47     }
 48     return Ret;
 49 }
 50
 51 const int N = 210;
 52 struct JediType {
 53     string Name;
 54     int a, b, c;
 55
 56     inline void Read() {
 57         cin>>Name;
 58         scanf("%d%d%d", &a, &b, &c);
 59     }
 60
 61     inline bool operator >(const JediType &T) const {
 62         return ((a >= T.a)+(b >= T.b)+(c >= T.c)) >= 2;
 63     }
 64 } Jedi[N];
 65 int n;
 66 bool F[N][N];
 67
 68 inline void Input() {
 69     scanf("%d", &n);
 70     For(i, 1, n) Jedi[i].Read();
 71 }
 72
 73 inline void Solve() {
 74     For(i, 1, n)
 75         For(j, 1, n)
 76             if(Jedi[i] > Jedi[j])
 77                 F[i][j] = 1;
 78
 79     For(k, 1, n)
 80         For(i, 1, n)
 81             For(j, 1, n)
 82                 F[i][j] |= F[i][k]&F[k][j];
 83
 84     For(i, 1, n) {
 85         bool Flag = 1;
 86         For(j, 1, n)
 87             if(!F[i][j]) {
 88                 Flag = 0;
 89                 break;
 90             }
 91         if(Flag) cout<<Jedi[i].Name<<endl;
 92     }
 93 }
 94
 95 int main() {
 96     #ifndef ONLINE_JUDGE
 97     SetIO("C");
 98     #endif
 99     Input();
100     Solve();
101     return 0;
102 }

时间: 2024-10-11 09:45:06

ural 1218. Episode N-th: The Jedi Tournament的相关文章

URAL 1551. Sumo Tournament(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1551 1551. Sumo Tournament Time limit: 1.0 second Memory limit: 64 MB A sumo tournament is held in Tokyo, in which 2N sportsmen take part. In each encounter there is a winner, and the loser drops out

cf gym 100960 G. Youngling Tournament set+树状数组

G. Youngling Tournament time limit per test 2 seconds memory limit per test 256 mebibytes input standard input output standard output Yoda, the Grand Master of the Jedi Order, hit on the idea to hold a tournament among younglings. He has not chosen t

URAL 1023 Buttons(巴什博弈水题)

1023. Buttons Time limit: 2.0 secondMemory limit: 64 MB Background As you surely already know, Yekaterinburg has gotten its right to hold The Summer Olympic Games of the 2032. It is planned that it will be allowed to Russia as a country-organizer to

URAL 1873. GOV Chronicles

唔 神题一道 大家感受一下 1873. GOV Chronicles Time limit: 0.5 secondMemory limit: 64 MB A chilly autumn night. Well wrapped up in a coat, a man is rapidly walking along a gray street. This is the Tradition Keeper of the ACM club in Ural State University. Drizzl

(校赛) URAL 1993 This cheeseburger you don&#39;t need

Master Yoda is the oldest member of the Jedi Council. He conducts preparatory classes of little Younglings up to the moment they get a mentor. All Younglings adore master Yoda and they hope to grow as strong and wise as he is. Just like all little ch

Ural 1081 Binary Lexicographic Sequence(DP)

题目地址:Ural 1081 先用dp求出每个长度下的合法序列(开头为1)的个数.然后求前缀和.会发现正好是一个斐波那契数列.然后每次判断是否大于此时长度下的最少个数,若大于,说明这一位肯定是1,若小于,则肯定是0.就这样不断输出出来即可. 代码如下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #in

URAL 1684. Jack&#39;s Last Word KMP

题目来源:URAL 1684. Jack's Last Word 题意:输入a b 把b分成若干段 每一段都是a的前缀 思路:b为主串 然后用a匹配b 记录到b的i位置最大匹配的长度 然后分割 分割的时候要从后往前 如果a = abac b = abab 那么如果从前往后 首先覆盖了aba 然后b就不能覆盖了 从后往前就可以了 首先覆盖ab 下一次还是ab 因为已经记录了到i位置的最大匹配长度 根据长度从末尾倒退 每次倒退的时候只要是最大的匹配的长度 因为如果在某一次的递推 记录的最大匹配的前缀

Emacs 安装 jedi

Jedi 是个很棒的 python 的自动补全插件,可以显示 docstring, function arguments and code location. 安装步骤: 一.安装 python 的虚拟环境 sudo apt-get install python-virtualenv 或 sudo apt-get install python-pip sudo pip install virtualenv 二.安装 jedi 在emacs里操作(一个朋友的帮助,干脆利落): 1. M-x: li

Rock-Paper-Scissors Tournament[HDU1148]

Rock-Paper-Scissors TournamentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2178 Accepted Submission(s): 693 Problem DescriptionRock-Paper-Scissors is game for two players, A and B, who each choo