Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void dump(const vector<string>& days,const vector<int>& count, int& x){
  8.     cout << count[x-1] << " ";
  9.     cout << days[x-1] << endl;
  10. }
  11.  
  12. void add(vector<string>& days,vector<int>& count, int& x, string& s){
  13.     days[x-1]+=s+" ";
  14.     count[x-1]++;
  15. }
  16.  
  17. void next(vector<string>& days,vector<int>& count,int& k){
  18.     if(k%12==0){
  19.         for(int i=28;i<31;i++){
  20.             days[27]+=days[i]+"";
  21.             count[27]+=count[i];
  22.             days[i]="";
  23.             count[i]=0;
  24.         }
  25.         days.resize(28);
  26.     } else if(days.size()<31){
  27.         days[29]+=days[30]+"";
  28.         count[29]+=count[30];
  29.         days[30]="";
  30.         count[30]=0;
  31.     } else days.resize(31);
  32.     k++;
  33. }
  34.  
  35. int main(){
  36.     int q,k,x;
  37.     string s,c;
  38.     vector<string> days(31);
  39.     vector<int> count(31);
  40.     k=12;
  41.     cin >> q;
  42.     for(int j=0; j<q;j++){
  43.         cin >> c;
  44.         if(c=="NEXT"){
  45.             next(days,count,k);
  46.         } else{
  47.             cin >> x;
  48.             if(c=="DUMP"){
  49.                 dump(days,count,x);
  50.             } else if(c=="ADD"){
  51.                 cin >> s;
  52.                 add(days,count,x,s);
  53.             }
  54.         }
  55.     }
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement