Advertisement
kirill1920

dairy

Jul 12th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. using namespace std;
  5. int main() {
  6.     vector <int> month = {31,28,31,30,31,30,31,30,31,30,30,31};
  7.     int mi = 0;
  8.     vector<vector<string>> tmp(month[mi]);
  9.     int n;
  10.     cin >> n;
  11.     for (int i = 0; i < n; ++i) {
  12.         string sel;
  13.         cin >> sel;
  14.         if (sel == "ADD") {
  15.             string work;
  16.             int day;
  17.             cin >> day >> work;
  18.             tmp[day - 1].push_back(work);
  19.  
  20.         }
  21.         else if (sel == "DUMP") {
  22.             int day;
  23.             cin >> day;
  24.             for (const auto& s : tmp[day - 1]) {
  25.                 cout << s << ' ';
  26.             }
  27.  
  28.         }
  29.         else if (sel == "NEXT") {
  30.             if (mi == 11) {
  31.                 mi = 0;
  32.             }
  33.             else if (mi != 11) {
  34.                 ++mi;
  35.                 if (month[mi] < month[mi - 1]) {
  36.                     vector<string> temp;
  37.                     tmp.resize(month[mi]);
  38.                     int index = 0;
  39.                     for (auto s : tmp) {
  40.                         ++index;
  41.                         for (auto t : s) {
  42.                             if (index > month[mi]) {
  43.                                 temp.push_back(t);
  44.                             }
  45.                         }
  46.                     }
  47.  
  48.                     tmp.insert(end(tmp), begin(temp), end(temp));
  49.  
  50.             }
  51.                 else if (month[mi] > month[mi - 1]) {
  52.                     ++mi;
  53.                     tmp.resize(month[mi]);
  54.  
  55.                 }
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement