Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- void vivodworry(const vector<bool>& vec) {
- for (auto g : vec) {
- cout << g;
- }
- cout << endl;
- }
- int main()
- {
- int i, j, n, m, count, r, size = 0;
- string comand;
- vector<bool> worry;
- vector<int> vivod;
- cin >> n;
- for (i = 0; i < n; i++) {
- cin >> comand;
- if (comand == "COME") {
- cin >> m;
- if (m >= 0) {
- for (j = 0; j < m; j++) {
- worry.push_back(false);
- }
- }
- else {
- for (j = 0; j < abs(m); j++) {
- size = worry.size() - 1;
- worry.erase(worry.begin() + size);
- }
- }
- }
- else if (comand == "WORRY") {
- cin >> m;
- worry[m] = true;
- }
- else if (comand == "QUITE") {
- cin >> m;
- worry[m] = false;
- }
- else if (comand == "WORRY_COUNT") {
- size = worry.size();
- int count = 0;
- for (j = 0; j < size; j++) {
- if (worry[j] == true)
- count += 1;
- }
- vivod.push_back(count);
- count = 0;
- }
- }
- for (auto c : vivod) {
- cout << c << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement