Alex_tz307

1218. Episode N-th: The Jedi Tournament - Timus

Nov 3rd, 2020 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class jedi {
  6.     public:
  7.         string name;
  8.         int x, y, z;
  9.  
  10.         bool operator > (const jedi &A) const {
  11.             return ((this -> x >= A.x) + (this -> y >= A.y) + (this -> z >= A.z)) > 1;
  12.         }
  13. };
  14.  
  15. int main() {
  16.     ios_base::sync_with_stdio(false);
  17.     cin.tie(nullptr);
  18.     cout.tie(nullptr);
  19.     int N;
  20.     cin >> N;
  21.     vector < vector < bool > > a(N + 1, vector < bool >(N + 1));
  22.     vector < jedi > v(N + 1);
  23.     for(int i = 1; i <= N; ++i)
  24.         cin >> v[i].name >> v[i].x >> v[i].y >> v[i].z;
  25.     for(int i = 1; i <= N; ++i)
  26.         for(int j = 1; j <= N; ++j)
  27.             if(v[i] > v[j])
  28.                 a[i][j] = true;
  29.     for(int k = 1; k <= N; ++k)
  30.         for(int i = 1; i <= N; ++i)
  31.             for(int j = 1; j <= N; ++j)
  32.                 a[i][j] = a[i][j] | (a[i][k] & a[k][j]);
  33.     for(int i = 1; i <= N; ++i) {
  34.         bool flag = true;
  35.         for(int j = 1; j <= N && flag; ++j)
  36.             flag &= a[i][j];
  37.         if(flag)
  38.             cout << v[i].name << '\n';
  39.     }
  40.  
  41. }
  42.  
Add Comment
Please, Sign In to add comment