damihenrique

Untitled

Jan 28th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <stdio.h>
  4. #include <cstring>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <utility>
  8. #include <queue>
  9. #include <map>
  10. #include <stack>
  11. #include <cmath>
  12. #include <set>
  13. #include <ctype.h>
  14. #include <bitset>
  15.  
  16. #define INF 0x3F3F3F3F
  17. #define rep(i, a, b) for (int i = int(a); i < int(b); i++)
  18. #define pb push_back
  19. #define clr(a) memset((a),0,sizeof(a))
  20. #define pi 3.1415926535897932384626433832795028841971
  21. #define debug(x) cout << #x << " = " << x << endl;
  22. #define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
  23. #define all(S) (S).begin(), (S).end()
  24. #define MAXV 1005
  25. #define F first
  26. #define S second
  27. #define EPS 1e-9
  28. #define mp make_pair
  29.  
  30. // freopen("in.txt", "r", stdin);
  31. // freopen("out.txt", "w", stdout);
  32.  
  33. using namespace std;
  34.  
  35. typedef long long ll;
  36. typedef pair < int, int >  ii;
  37. typedef vector < int >  vi;
  38. typedef vector < ii >  vii;
  39.  
  40. struct hotel{
  41.     char nome[33];
  42.     int d, p, q; //dist, preco, qualidade    
  43. };
  44.  
  45. hotel h[1011];
  46. bool dominado[1011];
  47.  
  48. int tenta(int x, int y){
  49.    
  50.     if(h[x].d > h[y].d && h[x].p >= h[y].p && h[x].q <= h[y].q)
  51.         return 1; // x dominado
  52.     if(h[x].d >= h[y].d && h[x].p > h[y].p && h[x].q <= h[y].q)
  53.         return 1;
  54.     if(h[x].d >= h[y].d && h[x].p >= h[y].p && h[x].q < h[y].q)
  55.         return 1;
  56.    
  57.     if(h[x].d < h[y].d && h[x].p <= h[y].p && h[x].q >= h[y].q)
  58.         return 2; // y dominado
  59.     if(h[x].d <= h[y].d && h[x].p < h[y].p && h[x].q >= h[y].q)
  60.         return 2;
  61.     if(h[x].d <= h[y].d && h[x].p <= h[y].p && h[x].q > h[y].q)
  62.         return 2;
  63.  
  64.     return 0;
  65. }
  66.  
  67. int main(){
  68.  
  69.     int n;
  70.    
  71.     while(scanf("%d",&n) && n){
  72.        
  73.         rep(i,0,n)
  74.             scanf(" %s%d%d%d",&h[i].nome,&h[i].d,&h[i].p,&h[i].q);  
  75.  
  76.         memset(dominado,false,sizeof(dominado));
  77.        
  78.         rep(i,0,n)
  79.         rep(j,i+1,n){
  80.            int a = tenta(i,j);
  81.            if(a == 1) dominado[i] = true;
  82.            else if(a == 2) dominado[j] = true;
  83.         }
  84.        
  85.         rep(i,0,n)
  86.             if(!dominado[i])
  87.                 cout<<h[i].nome<<"\n";  
  88.  
  89.         printf("*\n");
  90.     }
  91.  
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment