#include #include #include using namespace std; const int buy=1; const int sell=2; struct Bid { string agent; int bidtype; double price; }; vector bids; vector buys; vector sells; #define FOREACH(it,c) for(__typeof((c).begin())it=(c).begin();(it)!=(c).end();(it)++) int main(void) { while (true) { bids.clear(); buys.clear(); sells.clear(); int bidcount; string code; cin >> bidcount; cin >> code; if ((bidcount==0)&&(code.compare("END")==0)) break; for(int i=0;i> bid.agent; cin >> bidtype; if (bidtype.compare("sell")==0) bid.bidtype = sell; else bid.bidtype = buy; cin >> bid.price; bids.push_back(bid); if (bid.bidtype==sell) sells.push_back(bid); else buys.push_back(bid); } cout << code << "\n"; FOREACH(bid,bids) { cout << bid->agent << ":"; bool noone=true; if (bid->bidtype==buy) { FOREACH(sell,sells) { if (bid->price>=sell->price) { cout << " " << sell->agent; noone=false; } } } else { FOREACH(buy,buys) { if (bid->price<=buy->price) { cout << " " << buy->agent; noone=false; } } } if (noone) cout << " NO-ONE"; cout << "\n"; } } return 0; }