Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- vector<vector<string>> months, tasks;
- vector<int> days = { 31,28,31,30,31,30,31,31,30,31,30,31 };
- int checkMonths = 0;
- void add(string name, int day) {
- months[day-1].push_back(name);
- }
- void dump(int day) {
- tasks.resize(tasks.size() + 1);
- if (months[day - 1].size() != 0) {
- for (int i = 0; i < months[day - 1].size(); i++) {
- tasks.back().push_back(months[day - 1][i]);
- }
- }
- }
- void next() {
- checkMonths++;
- if (checkMonths > 11) checkMonths = 0;
- vector<vector<string>> nextMonth;
- nextMonth.resize(days[checkMonths]);
- for (int i = 0; i < months.size(); i++) {
- if (months[i].size() != 0) {
- if (i > nextMonth.size()) {
- for (auto x : months[i]) nextMonth[nextMonth.size()-1].push_back(x);
- }
- else {
- for (auto x : months[i]) nextMonth[i].push_back(x);
- }
- }
- }
- months = nextMonth;
- }
- int main()
- {
- int q;
- cin >> q;
- months.resize(days[checkMonths]);
- int day;
- string name, command;
- vector<int> dumps;
- for (int i = 0; i < q; i++) {
- cin >> command;
- if (command == "ADD") {
- cin >> day >> name;
- add(name, day);
- }
- else if (command == "DUMP") {
- cin >> day;
- dump(day);
- }
- else if (command == "NEXT") {
- next();
- }
- }
- for (int i = 0; i < tasks.size(); i++) {
- cout << tasks[i].size();
- if (tasks[i].size() != 0) {
- for (int j = 0; j < tasks[i].size(); j++) {
- cout << " " << tasks[i][j];
- }
- }
- cout << endl;
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement