PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000071. Tần suất lớn nhất trực tuyến (Mode)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tần suất lớn nhất trực tuyến (Mode)
Mode
Source: MarisaOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Queries are online. Each input pair is decoded using the previous answer : , , swapping if . Output the maximum frequency of any value in and set to this answer; initially .
Input
Read , the array and encoded pairs ; these are not direct interval endpoints.
Output
Print the mode frequency of each decoded interval.
Subtasks
- Subtask 1 (10 points): , . ; .
- Subtask 2 (20 points): , . ; .
- Subtask 3 (30 points): , . ; .
- Subtask 4 (40 points): , . ; .
Examples
Input
5 3
1 2 2 3 2
1 3
1 5
4 5
Output
2
1
1
Explanation
Initially ; input decodes to and values , so the answer is 2. Next with decodes to after swapping, with maximum frequency 1. The last query also returns 1.