#include #include #include #include #include using namespace std; struct bid { bid(bool t, string n, int a) { type = t; name = n; amount = a; } bool type; //0 = buy, 1 = sell string name; int amount; }; /* bool cmp_desc(struct bid a, struct bid b) { return (a.amount > b.amount); } bool cmp_asc(struct bid a, struct bid b) { return (a.amount < b.amount); } */ int main(void) { string issuer; string name, type, number, tmp; int nbids, amount; vector bids; //vector buyers; //vector sellers; while(1){ cin >> nbids >> issuer; if(nbids == 0 && issuer == "END") break; cout << issuer << endl; for(int i=0; i> name; cin >> type; cin >> tmp; for(string::iterator it = tmp.begin(); it < tmp.end(); it++){ if(*it == '.') continue; amount *= 10; amount += (*it - '0'); } bool btype = (type == "sell"); bids.push_back(bid(btype, name, amount)); /* if(btype){ sellers.push_back(bid(btype, name, amount)); }else{ buyers.push_back(bid(btype, name, amount)); } */ } //sort(bids.begin(), bids.end(), cmp); //sort(sellers.begin(), sellers.end(), cmp_desc); //sort(buyers.begin(), buyers.end(), cmp_asc); /* cout << "all bids:\n"; for(vector::iterator it = bids.begin(); it != bids.end(); it++){ cout << it->name << ": " << it->type << " " << it->amount << endl; } cout << "sellers:\n"; for(vector::iterator it = sellers.begin(); it != sellers.end(); it++){ cout << it->name << ": " << it->type << " " << it->amount << endl; } cout << "buyers:\n"; for(vector::iterator it = buyers.begin(); it != buyers.end(); it++){ cout << it->name << ": " << it->type << " " << it->amount << endl; } cout << "---\n"; */ for(vector::const_iterator it = bids.begin(); it != bids.end(); it++){ cout << it->name << ":"; bool noone = true; for(vector::const_iterator agent = bids.begin(); agent != bids.end(); agent++){ if(agent->name == it->name) continue; if(agent->type == false){ // buy if(it->type == false){ continue; }else if(it->amount <= agent->amount){ cout << " " << agent->name; noone = false; } }else{ //sell if(it->type == true){ continue; }else if(it->amount >= agent->amount){ cout << " " << agent->name; noone = false; } } if(agent->type == it->type) continue; } if(noone){ cout << " NO-ONE"; } cout << endl; } bids.erase(bids.begin(), bids.end()); //buyers.erase(buyers.begin(), buyers.end()); //sellers.erase(sellers.begin(), sellers.end()); } }