Question
Question#include#include#include#include#includeusing namespace std;struct Page { int id; string path; int counter; Page(int id, string path) { this->id = id; this->path = path; counter = 0;
Question#include#include#include#include#includeusing namespace std;struct Page { int id; string path; int counter; Page(int id, string path) { this->id = id; this->path = path; counter = 0; };};// This function can facilitate sortingbool operatorid = id; }; void add_visit(int page_id) { Page p(page_id, ""); vector::iterator iter = lower_bound(pages.begin(), pages.end(), p); if(iter->id == page_id) visits.push_back(iter->path); }; int size() const { return visits.size(); }; void print_visits() { sort(visits.begin(), visits.end()); vector::iterator iter; for(iter = visits.begin(); iter != visits.end(); iter++) { cout > type) { if(type == "USER") { int user_id; cin >> user_id; User u(user_id); add_user(u); } else if(type == "PAGE") { int page_id; string page_path; cin >> page_id; cin >> page_path; Page p(page_id, page_path); add_page(p); } else if(type == "VISIT") { int page_id; cin >> page_id; Page p(page_id, ""); vector::iterator iter = lower_bound(pages.begin(), pages.end(), p); if(iter->id == p.id) { iter->counter++; } add_visit(p.id); } } sort(pages.begin(), pages.end(), cmp_page_count); cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started