#include #include #include using namespace std; struct bid { string agentName; bool buy; float price; bid(string agentName, bool buy, float price) {this->agentName = agentName; this->buy = buy; this->price = price;}; }; vector bids; int main(int, char**) { int bidCount; string stockName; // nacteni vstupu do { cin >> bidCount; cin >> stockName; if (bidCount > 0) { bids.clear(); // nacist jednotlive nabidky/poptavky for (int i = 0; i < bidCount; i++) { string agentName; string buyString; float price; cin >> agentName; cin >> buyString; cin >> price; bids.push_back(bid(agentName, buyString == "buy", price)); } // vystup cout << stockName << endl; for (int i = 0; i < bidCount; i++) { cout << bids[i].agentName << ": "; int written = 0; for (int j = 0; j < bidCount; j++) { if ( (i != j) && ( ((bids[i].buy) && (!bids[j].buy) && (bids[i].price >= bids[j].price)) || ((!bids[i].buy) && (bids[j].buy) && (bids[i].price <= bids[j].price))) ) { if (written > 0) { cout << " "; } written++; cout << bids[j].agentName; } } if (written == 0) { cout << "NO-ONE"; } cout << endl; } } } while (bidCount > 0); return 0; }