Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- string s;
- map<string, vector<string>> buses, stops;
- for (int i = 0; i < n; i++) {
- cin >> s;
- if (s == "NEW_BUS") {
- cin >> s;
- int n;
- cin >> n;
- for (int j = 0; j < n; j++) {
- string stop;
- cin >> stop;
- buses[s].push_back(stop);
- stops[stop].push_back(s);
- }
- }
- if (s == "ALL_BUSES") {
- if (buses.empty())
- cout << "No buses" << endl;
- else {
- for (auto j : buses) {
- cout << "Bus " << j.first << ":";
- for (int k = 0; k < j.second.size(); k++) {
- cout << " " << j.second[k];
- }
- cout << endl;
- }
- }
- }
- if (s == "STOPS_FOR_BUS") {
- cin >> s;
- if (buses.find(s) == buses.end())
- cout << "No bus" << endl;
- else {
- for (int j = 0; j < buses[s].size(); j++) {
- string stop = buses[s][j];
- cout << "Stop " << stop << ":";
- if (stops[stop].size() == 1)
- cout << " no interchange" << endl;
- else {
- for (int k = 0; k < stops[stop].size(); k++) {
- if (stops[stop][k] != s)
- cout << " " << stops[stop][k];
- }
- cout << endl;
- }
- }
- }
- }
- if (s == "BUSES_FOR_STOP") {
- cin >> s;
- if (stops.find(s) == stops.end())
- cout << "No stop";
- else {
- for (int j = 0; j < stops[s].size(); j++) {
- cout << stops[s][j] << " ";
- }
- }
- cout << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement