Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <cstring>
- #include <vector>
- #include <algorithm>
- #include <utility>
- #include <queue>
- #include <map>
- #include <stack>
- #include <cmath>
- #include <set>
- #include <ctype.h>
- #include <bitset>
- #define INF 0x3F3F3F3F
- #define rep(i, a, b) for (int i = int(a); i < int(b); i++)
- #define pb push_back
- #define clr(a) memset((a),0,sizeof(a))
- #define pi 3.1415926535897932384626433832795028841971
- #define debug(x) cout << #x << " = " << x << endl;
- #define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
- #define all(S) (S).begin(), (S).end()
- #define MAXV 1005
- #define F first
- #define S second
- #define EPS 1e-9
- #define mp make_pair
- // freopen("in.txt", "r", stdin);
- // freopen("out.txt", "w", stdout);
- using namespace std;
- typedef long long ll;
- typedef pair < int, int > ii;
- typedef vector < int > vi;
- typedef vector < ii > vii;
- struct hotel{
- char nome[33];
- int d, p, q; //dist, preco, qualidade
- };
- hotel h[1011];
- bool dominado[1011];
- int tenta(int x, int y){
- if(h[x].d > h[y].d && h[x].p >= h[y].p && h[x].q <= h[y].q)
- return 1; // x dominado
- if(h[x].d >= h[y].d && h[x].p > h[y].p && h[x].q <= h[y].q)
- return 1;
- if(h[x].d >= h[y].d && h[x].p >= h[y].p && h[x].q < h[y].q)
- return 1;
- if(h[x].d < h[y].d && h[x].p <= h[y].p && h[x].q >= h[y].q)
- return 2; // y dominado
- if(h[x].d <= h[y].d && h[x].p < h[y].p && h[x].q >= h[y].q)
- return 2;
- if(h[x].d <= h[y].d && h[x].p <= h[y].p && h[x].q > h[y].q)
- return 2;
- return 0;
- }
- int main(){
- int n;
- while(scanf("%d",&n) && n){
- rep(i,0,n)
- scanf(" %s%d%d%d",&h[i].nome,&h[i].d,&h[i].p,&h[i].q);
- memset(dominado,false,sizeof(dominado));
- rep(i,0,n)
- rep(j,i+1,n){
- int a = tenta(i,j);
- if(a == 1) dominado[i] = true;
- else if(a == 2) dominado[j] = true;
- }
- rep(i,0,n)
- if(!dominado[i])
- cout<<h[i].nome<<"\n";
- printf("*\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment