Advertisement
Guest User

ochered

a guest
Oct 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. void vivodworry(const vector<bool>& vec) {
  9.     for (auto g : vec) {
  10.         cout << g;
  11.     }
  12.     cout << endl;
  13. }
  14.  
  15. int main()
  16. {
  17.     int i, j, n, m, count, r, size = 0;
  18.     string comand;
  19.     vector<bool> worry;
  20.     vector<int> vivod;
  21.     cin >> n;
  22.  
  23.     for (i = 0; i < n; i++) {
  24.         cin >> comand;
  25.         if (comand == "COME") {
  26.             cin >> m;
  27.             if (m >= 0) {
  28.                 for (j = 0; j < m; j++) {
  29.                     worry.push_back(false);
  30.                 }
  31.             }
  32.             else {
  33.                 for (j = 0; j < abs(m); j++) {
  34.                     size = worry.size() - 1;
  35.                     worry.erase(worry.begin() + size);
  36.                 }
  37.             }
  38.         }
  39.         else if (comand == "WORRY") {
  40.             cin >> m;
  41.             worry[m] = true;
  42.         }
  43.         else if (comand == "QUITE") {
  44.             cin >> m;
  45.             worry[m] = false;
  46.         }
  47.         else if (comand == "WORRY_COUNT") {
  48.             size = worry.size();
  49.             int count = 0;
  50.             for (j = 0; j < size; j++) {
  51.                 if (worry[j] == true)
  52.                     count += 1;
  53.             }
  54.             vivod.push_back(count);
  55.             count = 0;
  56.         }
  57.     }
  58.     for (auto c : vivod) {
  59.         cout << c << endl;
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement