#include #include #include using namespace std; #define MAX_N 1001 struct bidder { char name[26]; bool sell; // kdyz ==false, tak buy double prize; }; bidder bids[MAX_N]; void process_stock(int n) { // load input char tmp[10]; for (int i = 0; i < n; i++) { scanf("%s %s %lf", bids[i].name, tmp, &bids[i].prize); if (strcmp(tmp, "sell") == 0) { bids[i].sell = true; } else { bids[i].sell = false; } } // print output for (int i = 0; i < n; i++) { printf("%s:", bids[i].name); int matches = 0; for (int j = 0; j < n; j++) { if (i == j) continue; if (bids[i].sell == bids[j].sell) continue; if (bids[i].sell && bids[i].prize <= bids[j].prize) { printf(" %s", bids[j].name); matches++; } if (!bids[i].sell && bids[i].prize >= bids[j].prize) { printf(" %s", bids[j].name); matches++; } } if (matches == 0) printf(" NO-ONE"); printf("\n"); } } int main(int argc, char* argv[]) { while (true) { int n; char name[12]; scanf("%d %s", &n, name); if (n == 0 && strcmp(name, "END") == 0) break; printf("%s\n", name); process_stock(n); } return 0; }