Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <string>
- #include <map>
- void next(int month, std::map<int, std::vector<std::string>>& tasks)
- {
- int months[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- if (months[month] < months[month-1])
- {
- for (int i = months[month-1]; i > months[month]; --i)
- {
- for(const auto& t : tasks[i])
- {
- tasks[months[month]].push_back(t);
- }
- tasks[i].clear();
- }
- }
- }
- void add(std::map<int, std::vector<std::string>>& tasks) {
- int day;
- std::cin >> day;
- std::string task;
- std::cin >> task;
- tasks[day].push_back(task);
- }
- void dump(std::map<int, std::vector<std::string>>& tasks)
- {
- int day;
- std::cin >> day;
- std::cout << tasks[day].size() << " ";
- for (const auto& t : tasks[day])
- {
- std::cout << t << " ";
- }
- std::cout << std::endl;
- }
- int main()
- {
- int q;
- std::cin >> q;
- std::map<int, std::vector<std::string>> tasks;
- int month = 0;
- for (int i = 0; i < q; i++)
- {
- std::string action;
- std::cin >> action;
- if (action == "NEXT") {
- month += 1;
- next(month, tasks);
- }
- else
- {
- if (action == "ADD") {
- add(tasks);
- }
- else if(action == "DUMP")
- {
- dump(tasks);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment