Advertisement
drof13

ошибка оформления

Oct 3rd, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <map>
  7. #include <set>
  8. #include <iterator>
  9.  
  10. #define int long long
  11.  
  12. using namespace std;
  13.  
  14. signed main() {
  15.     int n, m, k;
  16.     cin >> n >> m >> k;
  17.     vector<set<int>> v(m);
  18.     for (int i = 0; i < k; i++) {
  19.         string command;
  20.         cin >> command;
  21.         if (command == "ADD") {
  22.             int e, s;
  23.             cin >> e >> s;
  24.             v[s].insert(e);
  25.             continue;
  26.         }
  27.         if (command == "DELETE") {
  28.             int e, s;
  29.             cin >> e >> s;
  30.             v[s].erase(v[s].find(e));
  31.             continue;
  32.         }
  33.         if (command == "CLEAR") {
  34.             int s;
  35.             cin >> s;
  36.             v[s].clear();
  37.             continue;
  38.         }
  39.         if (command == "LISTSET") {
  40.             int s;
  41.             cin >> s;
  42.             bool is_exist = false;
  43.             set<int>::iterator it = v[s].begin();
  44.             for (; it != v[s].end(); it++) {
  45.                 is_exist = true;
  46.                 cout << *it << " ";
  47.             }
  48.             if (is_exist == false) {
  49.                 cout << -1 << '\n';
  50.             }
  51.             else {
  52.                 cout << '\n';
  53.             }
  54.             continue;
  55.         }
  56.         if (command == "LISTSETSOF") {
  57.             int e;
  58.             cin >> e;
  59.             bool is_exist = false;
  60.             for (int i = 0; i < m; i++) {
  61.                 if (v[i].find(e) != v[i].end()) {
  62.                     is_exist = true;
  63.                     cout << i << " ";
  64.                 }
  65.             }
  66.             if (is_exist == false) {
  67.                 cout << -1 << '\n';
  68.             }
  69.             else {
  70.                 cout << '\n';
  71.             }
  72.         }
  73.     }
  74. }
  75.  
  76.  
  77.  
  78. или
  79.  
  80. #include <algorithm>
  81. #include <cmath>
  82. #include <iostream>
  83. #include <iterator>
  84. #include <map>
  85. #include <set>
  86. #include <string>
  87. #include <vector>
  88.  
  89. #define int long long
  90.  
  91. using namespace std;
  92.  
  93. signed main()
  94. {
  95.     int n, m, k;
  96.     cin >> n >> m >> k;
  97.     vector<set<int>> v(m);
  98.     for (int i = 0; i < k; i++) {
  99.         string command;
  100.         cin >> command;
  101.         if (command == "ADD") {
  102.             int e, s;
  103.             cin >> e >> s;
  104.             v[s].insert(e);
  105.             continue;
  106.         }
  107.         if (command == "DELETE") {
  108.             int e, s;
  109.             cin >> e >> s;
  110.             v[s].erase(v[s].find(e));
  111.             continue;
  112.         }
  113.         if (command == "CLEAR") {
  114.             int s;
  115.             cin >> s;
  116.             v[s].clear();
  117.             continue;
  118.         }
  119.         if (command == "LISTSET") {
  120.             int s;
  121.             cin >> s;
  122.             bool is_exist = false;
  123.             set<int>::iterator it = v[s].begin();
  124.             for (; it != v[s].end(); it++) {
  125.                 is_exist = true;
  126.                 cout << *it << " ";
  127.             }
  128.             if (is_exist == false) {
  129.                 cout << -1 << '\n';
  130.             } else {
  131.                 cout << '\n';
  132.             }
  133.             continue;
  134.         }
  135.         if (command == "LISTSETSOF") {
  136.             int e;
  137.             cin >> e;
  138.             bool is_exist = false;
  139.             for (int i = 0; i < m; i++) {
  140.                 if (v[i].find(e) != v[i].end()) {
  141.                     is_exist = true;
  142.                     cout << i << " ";
  143.                 }
  144.             }
  145.             if (is_exist == false) {
  146.                 cout << -1 << '\n';
  147.             } else {
  148.                 cout << '\n';
  149.             }
  150.         }
  151.     }
  152. }
  153.  
  154.  
  155.  
  156.  
  157.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement