Python Bài 7.B1: Phân tích lịch sử trình duyệt


LÀM BÀI

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Python

Mô tả bài toán

Xây dựng hệ thống phân tích lịch sử duyệt web với các chức năng:

  1. Thêm/xóa lịch sử truy cập
  2. Phân loại website theo domain
  3. Thống kê thời gian truy cập
  4. Tìm pattern duyệt web

INPUT FORMAT

  • Dòng 1: N - số lệnh
  • N dòng tiếp theo, mỗi lệnh:
    • VISIT time url duration: thêm lượt truy cập
    • DELETE time: xóa lượt truy cập
    • DOMAIN domain: thống kê theo domain
    • TIME start end: thống kê theo khoảng thời gian
    • PATTERN k: tìm k website truy cập liên tiếp nhiều nhất

OUTPUT FORMAT

  • VISIT: "Added"
  • DELETE: "Deleted" hoặc "Not found"
  • DOMAIN: Số lượt truy cập và tổng thời gian
  • TIME: Các website truy cập trong khoảng thời gian
  • PATTERN: Chuỗi k website xuất hiện nhiều nhất

VÍ DỤ

Input:
6
VISIT 09:00 google.com 10
VISIT 09:15 facebook.com 20
VISIT 09:40 google.com 15
TIME 09:00 09:30
DOMAIN google.com
PATTERN 2
Output:
Added
Added
Added
Websites (09:00-09:30):
- google.com (10m)
- facebook.com (20m)
google.com:
- Visits: 2
- Total time: 25m
Most common pattern:
google.com -> facebook.com (1 time)

Giải thích

  • Lưu trữ: {time: {url, duration}}
  • Domain: Gom nhóm theo tên miền
  • Time: Lọc theo khoảng thời gian
  • Pattern: Tìm chuỗi con liên tiếp

Comments

There are no comments at the moment.

Zalo