标签:
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 |
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 }
ural 1218. Episode N-th: The Jedi Tournament
标签:
原文地址:http://www.cnblogs.com/StupidBoy/p/4893056.html